Part III. Reorganizing Your Code
In Part II, we discussed how to change the âloops and logicâ of your program to make your code more readable. We described several techniques that required changing the structure of your program in minor ways.
In this part, weâll discuss larger changes you can make to your code at the function level. Specifically, weâll cover three ways to reorganize your code:
Extract âunrelated subproblemsâ that arenât related to the primary goal of your program.
Rearrange your code so itâs doing only one task at a time.
Describe your code in words first, and use this description to help guide you to a cleaner solution.
Finally, weâll discuss situations where you can remove code entirely or avoid writing it in the first placeâthe single best way to make code easy to understand.
Get The Art of Readable Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.