Refactoring, Improving the Design of Existing Code, Addison-Wesley
C# Online.NET Book Review
Refactoring is a risky procedure that dates back to the advent of the SmallTalk programming language. But, it has since spread to all modern languages; and, it is considered critical in framework and class library development—because a framework is never right on the first iteration.
Whether refactoring as a discipline is a workable practice is controversial. Adherents lobby for more disciplined restructuring and testing while doubters claim real life refactoring is impractical and tricky.
The book comprises an introduction to refactoring plus a catalog of some seventy refactoring tips. Each "refactoring" includes the before and after source code and an explanation of the refactoring process in this case. As with patterns, each refactoring is given a simple name, a motivation, and examples written in Java and documented in Unified Modeling Language (UML). While early chapters reiterate the importance of testing in successful refactoring, later chapters offer a quick look ahead into refactoring research.
The book teaches:
- what the refactoring process is;
- why one should refactor;
- where one should refactor—the signs suggesting a need for refactoring;
- how to refactoring—step-by-step tutorials.
The book covers the following topics:
- design patterns,
- design tips,
- improving source code,
- refactoring research,
- refactoring tools,
- unit testing.
Our author is a software patterns expert. And, he makes this book a success by presenting the refactoring concepts and application with remarkable clarity. And, his advice is both practical and authoritative. Another favorite book of mine by Fowler is UML Distilled.
All the source code examples are in the Java language.
Martin Fowler's Refactoring is the most lucid, most authoritative, most complete exposition of refactoring.
From the back cover
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.
About the author(s)
Martin Fowler is an independent consultant who has applied objects to pressing business problems for more than a decade. He has consulted on systems in fields such as health care, financial trading, and corporate finance. His clients include Chrysler, Citibank, UK National Health Service, Andersen Consulting, and Netscape Communications. In addition, Fowler is a regular speaker on objects, the Unified Modeling Language, and patterns.
Table of Contents (abbreviated)
- 1. Refactoring, a First Example.
- 2. Principles in Refactoring.
- 3. Bad Smells in Code.
- 4. Building Tests.
- 5. Toward a Catalog of Refactorings.
- 6. Composing Methods.
- 7. Moving Features Between Objects.
- 8. Organizing Data.
- 9. Simplifying Conditional Expressions.
- 10. Making Method Calls Simpler.
- 11. Dealing with Generalization.
- 12. Big Refactorings.
- 13. Refactoring, Reuse, and Reality.
- 14. Refactoring Tools.
- 15. Putting It All Together.