Chapter 7. Unnecessary Complexity

Code is sometimes more complicated than it would have to be purely to solve the problem at hand. There are three main causes for this problem:

• Code shows the traces of its history, the leftovers from old ways of doing things; the current complexity of the code owes more to the past—and to the journey travelled—than to the present.

• The design has been over-generalized. This is often done in anticipation of future requirements, or for premature performance tuning.

• The original developers were unfamiliar with Ruby—they didn’t know that there was a language feature or a library method that does what they needed.

Remove these problems when you run into them. You’ll often find that this can lead to further ...

Get Refactoring in Ruby 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.