working with legacy rails apps - ahmed omran

38
Working With Legacy Rails Apps @this_ahmed

Upload: ottawaruby

Post on 11-Jan-2017

246 views

Category:

Software


4 download

TRANSCRIPT

Working With Legacy Rails Apps

@this_ahmed

Working With Legacy Rails Apps

@this_ahmed

legacy code• untested code (Michael C. Feathers)

• code someone else wrote (old gems, outsourcing, maintainers left)

• difficult to work with

• risky to change

• but serves a useful function

googling legacy code …

every project has legacy code?

• learning & experimenting

• ambitious applications

• big project, developer churn, hiring outside help

• bad code … even with the best of intentions

• “Technical debt”

–Robert C. Martin

“Even the most disciplined development team, knowing the best principles, using the best

patterns, and following the best practices will create messes from time to time.”

in the face of legacy code you can …

or…

Useful techniques

Rebuild Refactor

–Robert C. Martin

“…taking a tangled, opaque, convoluted system and slowly, gradually, piece by piece, step by step, turning it into a simple, nicely

structured, well-designed system.”

Boy Scout Rule Clean up around you work area. Small fixes; small

refractors.

cover and modify

• add unit test

• test passes

• modify code

• test passes

use mock objects to break dependencies

mock dependencies

break complicated dependencies with

seams

seam => put in method + stub

first step to later refactor

i don’t understand this code…

Ask someone

code archeology

code archeology

git blame / Github

code archeologysearch code for context

git blame / Github

code archeology

project management ticket

git blame / Github

search code for context

code archeology

git blame / Github project management ticket

commit messagesearch code for context

review

• boy scout rule

• cover and modify

• break dependencies with mocks and seams

• understand code with archeology

some parting thoughts

unit test

• code review

• small git branches

• add lots of context in pull request / commit message