Chapter 6. Composing Methods
A large part of my refactoring is composing methods to package code properly. Almost all the time the problems come from methods that are too long. Long methods are troublesome because they often contain lots of information, which gets buried by the complex logic that usually gets dragged in. The key refactoring is Extract Method (110), which takes a clump of code and turns it into its own method. Inline Method (117) is essentially the opposite. You take a method call and replace it with the body of the code. I need Inline Method (117) when I’ve done multiple extractions and realize some of the resulting methods are no longer pulling their weight or if I need to reorganize the way I’ve broken down methods.
The biggest ...
Get Refactoring: Improving the Design of Existing 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.