_TOP_MENU

Feb 11, 2023

What is the best way to understand complex legacy code?

 Find one thing you understand in the code and start from there. Don’t go down the rabbit hole and start reading every function in the class. Following the code like a machine would step through a set of instructions. This should have you build a mental model of all the pieces needed to get to the bottom line.


Do this Once: For a very high level understanding.
Again: For a deeper understanding and clarifying assumptions.
Again: Until most assumptions are gone.

Finally - stick to one operation/outcome/feature -then read the code to find your answer. This will build on your understanding.

Jumping into the codebase because you need to know how it works is pointless unless you have a goal in mind. Focus on a specific feature you would like to understand or evaluate how the code is solving a specific problem.

Don’t lose site of this goal, take in bite size chunks till you can connect all the dots.

Rinse and repeat - usually while trying to solve a problem by adding to this codebase yourself, I find, is the fastest and most reliable way to understand complexity and also retain that understanding for longer.

No comments:

Post a Comment