Reading code is sometimes so difficult that developers will simply give up and complain loudly that they need to rewrite the code from scratch because it is so incomprehensible. (Preferably the rewrite will be in a fancy new language or framework they have just heard about at a conference). I can totally understand the sentiment but it’s almost always a mistake to rewrite valuable working code from scratch. On the other hand legacy code can sometimes be very challenging to read, with long sections of complex logic and obtuse names. Unfortunately despite it being a crucial skill - we spend more time reading code than writing it - most people are never taught code reading strategies.
In this presentation I will go through some of the techniques I use that are effective even when you have legacy code. My goal is always to quickly get to the point where I understand enough context to find the part I need to change, and to do that safely. I always want to leave the code in a more readable state than I found it, to help the next person. I’ll discuss “Scanning”, effective use of your code editor tooling, and “Naming as a Process”. We’ll go through a code reading training exercise together and I’ll show lots of examples. Next time someone claims some code is incomprehensible you might be able to help them avoid that expensive and risky rewrite.