Refactoring to Cleaner Code
Learn some best practices for refactoring your code.
Why code refactoring?
Our systems are bloated! We can pick almost any system at random and spot obvious bits of rampant duplication. They could be a hundred-line-long method that’s an almost complete replication from another class or just a few lines of utility code repeated over and over.
The cost of such duplication is significant. Every piece of code duplicated increases the cost to maintain it as well as the risk of making a change. We want to minimize the amount of duplication in our system’s code.
The cost of understanding code is also significant. A change requiring ten minutes of effort in clear, well-structured code can take hours of effort in convoluted, muddy code. We want to maximize the clarity of our system’s code.
If we can accomplish both goals—low ...