Refactoring by Martin Fowler

Improve the design of existing code

"Any fool can write code that computer can understand. Good programmers write code that humans can understand."

Refactoring can feel like a risky venture, to the unintiated. Working with fragile code or not being aware of good refactoring techniques, leaves a lot of room for things to break. Further it can take a huge toll congnitively, and result in poor use of cognitive and time resources. However if done correctly it can make programs wonderfully maintainable, re-usable and valuable.

Refactoring was first published in 1999, and had a profound effect on many a programmer's lives. In the second edition the original author Martin Fowler teams up with Kent Beck, to provide a revised version. Fowler, a Chief Scientist at ThoughtWorks, concentrates on designing enterprise software.

The book can be broken down into two major parts. The first part takes up roughly 30% of the books and provides an explanation of refactoring. This section can be read on its own, and there is much to be gained just by reading this first 3 chapters.

The second part involves a comprehensive taxonomy of refactorings. Each of the 61 refactorings are comprehensively introduced, providing a name, a diagram, a snapshot example, explanation, and a worked example. In fact these refactorings are a compilation of Martin's notes and checklists of refactorings. They serve well as a reference guide when coming across such refactorings. The code examples are all neat, and provided in Javascript, however they are provided in a way that it is easy to see how they could be applied in other programming languages. It is has heavy references to Object Orientated Programming, and is well suited to those who are well verse in such techniques. I highly recommended those who are not, to refresh themselves on the topic, prior to going through the taxonomy of classifications.

In addition to the two major parts, Fowler includes a brief chapter on testing and emphasises that good tests are the backbone of any refactoring exercise. The book provides a fantastic reference manual for refactorings, inside the front cover a list of all of these are provided, and the back cover has a list of all the 'Smells' and suggested refactorings to cure these.

Spread across the book Fowler and Beck, sprinkly a little unique humour as they share their observations and expereince from undertaking many refactorings in enterprise software. Some of the notable takeaways for me included the following:

The second edition, is an invaluable reference for anyone interested in writing better code. While reading the book, many programmers will enjoy reading about their pet peeves in code structure and also see favourite moves in editing code be soo eloquently described. It creates an appreciation of how truely malleable code is and how easy it can be to update, putting you back in the driver's seat. The book is a classic and must-read for anyone interested in the Art of Programming.

 

 

Tags: