Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Overview

As the application of object technology--particularly the Java programming language--has become commonplace, a new problem has emerged to confront the software development community. Significant numbers of poorly designed programs have been created by less-experienced developers, resulting in applications that are inefficient and hard to maintain and extend. Increasingly, software system professionals are discovering just how difficult it is to work with these inherited, "non-optimal" applications. For several years, expert-level object programmers have employed a growing collection of techniques to improve the structural integrity and performance of such existing software programs. Referred to as "refactoring," these practices have remained in the domain of experts because no attempt has been made to transcribe the lore into a form that all developers could use. . .until now. In Refactoring: Improving the Design of Existing Code, renowned object technology mentor Martin Fowler breaks new ground, demystifying these master practices and demonstrating how software practitioners can realize the significant benefits of this new process.

With proper training a skilled system designer can take a bad design and rework it into well-designed, robust code. In this book, Martin Fowler shows you where opportunities for refactoring typically can be found, and how to go about reworking a bad design into a good one. Each refactoring step is simple--seemingly too simple to be worth doing. Refactoring may involve moving a field from one class to another, or pulling some code out of a method to turn it into its own method, or even pushing some code up or down a hierarchy. While these individual steps may seem elementary, the cumulative effect of such small changes can radically improve the design. Refactoring is a proven way to prevent software decay.

In addition to discussing the various techniques of refactoring, the author provides a detailed catalog of more than seventy proven refactorings with helpful pointers that teach you when to apply them; step-by-step instructions for applying each refactoring; and an example illustrating how the refactoring works. The illustrative examples are written in Java, but the ideas are applicable to any object-oriented programming language.

Subscriber Reviews

Average Rating: 4.739130434782608 out of 5 rating Based on 23 Ratings

"nice read... ??" - by Rahul Baphana on 07-JAN-2014
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
helps refactoring legacy code and providing unit test coverage.
Report as Inappropriate

"A great book that shouldn't be read linearly " - by David Ryder on 13-AUG-2012
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Chapter 1 and 2 was pretty easy to get through, then there was chapter 3. Chapter 3 lists common code smells/antipatterns and ways to address them. I don't recommend reading straight through this chapter.

Each antipattern is addressed with several refactoring methods with the page number to learn about it. I spent a lot of time on this chapter as every antipattern had several methods that sometimes referenced other refactoring methods. Sometimes it seemed I was never going to finish the chapter, but I knocked out a lot of chapters 5-11 this way.

As a bonus I got to learn a fair amount of Java as all the examples are written in Java. I used Effective Java as a reference to anything I didn't fully understand.

The book was easy to read and it really helped to illustrate how to deal with code smells in a very pragmatic way. One of the problems with a lot of articles/books is they lack solid examples that turn the theory into practice.

Report as Inappropriate

"A must read" - by NCornillon on 26-JUL-2012
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Martin Fowler is my favorite tech writer.  This is one of my two favorite books of his.

The first part of the book defines what refactoring is, why it is important, and how to include it in your process.  This part of the book is quick, easy reading that you can get through quickly.

The majority of the book are refactoring "patterns" - step-by-step instructions for how to go through common refactoring.  It is a great resource.

You say, "But my IDE has refactoring built into it, so why do I need to know this?"

Having the toolset doesn't mean you know how and when to use them, or which one of the tools to use.  Also, good chance your refactoring tool doesn't have all of the refactors listed here.


Report as Inappropriate

"The one that started it all!" - by Peter Tran on 14-MAR-2011
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Refactoring: Improving the Design of Existing Code reminds me of the line from the Lord of the Rings novel (slightly modified): One [Book] to rule them all, One [Book] to find them, One [Book] to bring them all in the [lightness] bind them. First published in 1999, the advice is still relevant today as it was then.
The book is broken into 3 main sections:  
Chapters 1 – 4 covers the reason why refactoring is so important.  Chapter 1 walks through an example taking a very procedural code and applies several refactoring methodology to transform the code into one that is easier to test and maintain and less fragile. Chapter 2 covers the principle of refactoring and answers questions on why refactoring is important.  Chapter 3 discusses what type of code is prime candidate for refactoring – “code smell”. Chapter 4 discusses the importance of building tests before refactoring.  
Chapters 5 – 11 catalog all the different refactoring technique.  For each refactoring technique, the author provides a name, a short summary, motivation, mechanics, and example demonstrating how to apply the refactoring technique.  The examples are excellent and invaluable.
Chapters 12 – 15 are co-written with other authors using real-world examples (war-stories). These will help you see the bigger picture and how refactoring fits into the bigger picture of software development.
I recommend completely reading chapters 1 – 4 in order, and then peruse chapters 6 – 11 to get an idea on each refactoring technique. You can go back to refers to these chapters to study the examples. Chapters 12 – 15 can be read independently, but will have more meaning once you’ve done a few refactoring exercises.
The keys to good refactoring are good test cases and knowing when which technique should be use for the given situation. There has been other books written on the subject for different languages, but this one started it all. This book is only available in hardback version, which is good because it’s going to get a lot of use.

Report as Inappropriate

"very useful" - by Anonymous on 09-DEC-2010
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
IMO, you can't say you are a skilled OO programmer until you read this book.
Report as Inappropriate

Table of Contents