Chapter 11Refactoring APIs
Modules and their functions are the building blocks of our software. APIs are the joints that we use to plug them together. Making these APIs easy to understand and use is important but also difficult: I need to refactor them as I learn how to improve them.
A good API clearly separates any functions that update data from those that only read data. If I see them combined, I use Separate Query from Modifier (306) to tease them apart. I can unify functions that only vary due to a value with Parameterize Function (310). Some parameters, however, are really just a signal of an entirely different behavior and are best excised with Remove Flag Argument (314).
Data structures are often unpacked unnecessarily when passed between ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access