|
| Refactoring: Improving the Design of Existing Code (Addison-Wesley Object Technology Series) | 
enlarge | Authors: Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts Publisher: Addison-Wesley Professional Category: Book
List Price: $59.99 Buy New: $38.00 You Save: $21.99 (37%)
New (33) Used (11) from $38.00
Avg. Customer Rating: 139 reviews Sales Rank: 10655
Media: Hardcover Number Of Items: 1 Pages: 464 Shipping Weight (lbs): 2.7 Dimensions (in): 9.3 x 7.6 x 1.3
ISBN: 0201485672 Dewey Decimal Number: 005.14 UPC: 785342485677 EAN: 9780201485677 ASIN: 0201485672
Publication Date: July 8, 1999 Availability: Usually ships in 1-2 business days Condition: Brand new, mint condition. Hardcover. Never read copy. Binding intact. Ships same day or next day!
|
| Also Available In:
|
| Accessories:
|
| Similar Items:
|
| Editorial Reviews:
Amazon.com Your class library works, but could it be better? Refactoring: Improving the Design of Existing Code shows how refactoring can make object-oriented code simpler and easier to maintain. Today refactoring requires considerable design know-how, but once tools become available, all programmers should be able to improve their code using refactoring techniques. Besides an introduction to refactoring, this handbook provides a catalog of dozens of tips for improving code. The best thing about Refactoring is its remarkably clear presentation, along with excellent nuts-and-bolts advice, from object expert Martin Fowler. The author is also an authority on software patterns and UML, and this experience helps make this a better book, one that should be immediately accessible to any intermediate or advanced object-oriented developer. (Just like patterns, each refactoring tip is presented with a simple name, a "motivation," and examples using Java and UML.) Early chapters stress the importance of testing in successful refactoring. (When you improve code, you have to test to verify that it still works.) After the discussion on how to detect the "smell" of bad code, readers get to the heart of the book, its catalog of over 70 "refactorings"--tips for better and simpler class design. Each tip is illustrated with "before" and "after" code, along with an explanation. Later chapters provide a quick look at refactoring research. Like software patterns, refactoring may be an idea whose time has come. This groundbreaking title will surely help bring refactoring to the programming mainstream. With its clear advice on a hot new topic, Refactoring is sure to be essential reading for anyone who writes or maintains object-oriented software. --Richard Dragan Topics Covered: Refactoring, improving software code, redesign, design tips, patterns, unit testing, refactoring research, and tools.
Book Description 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 Software, 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.
|
| Customer Reviews: Read 134 more reviews...
Recipes for improving code May 5, 2000 123 out of 129 found this review helpful
Like the Gang of Four's landmark book _Design Patterns_, Fowler and his cohorts have created another catalog-style book, this time on refactoring.Refactoring refers to taking existing, working software, and changing it about to improve its design, so that future modifications and enhancements are easier to add. _Refactoring_ is primarily a catalog of 70 or so different kinds of improvements you can make to object-oriented software. Each entry in the catalog describes an implementation problem, the solution, motivation for applying the solution, the mechanics of the refactoring, and examples. The book's examples are all in Java, but C++ programmers should be able to approach the refactorings with ease. Often, Fowler diagrams the refactorings in UML, so a little Unified Modeling Language experience will help, too. While the catalog is nice, the kinds of refactorings are obvious is most cases. Even moderately experienced programmers won't need the step-by-step mechanics described. The real benefit, though, is that the mechanics of each refactoring help guarantee that you can pull off the refactoring without introducing new bugs or side effects. They encourage you to take smaller, verifiable steps, than the more gross refactorings that most developers would naturally take. You actually save time doing so. How do you know your refactorings are safe? Unit testing is the answer that Fowler et al. provide. Java developers will find the introduction to the Junit Testing Framework the most valuable part of the book, more so than the catalog of refactorings itself. There's more to the book than the catalog and Junit, of course. There's discussion of the history of refactoring, how to evaluate refactoring tools, and how to convince management that what appears to be an overhead activity is actually useful in the long run. Unfortunately, these sections are all too brief. And there is no discussion of how refactoring fits in with various software development processes. For example, programmers using Extreme Programming (XP) would probably feel right at home with Fowler's recommendations of refactoring in duets and unit testing, but developers stuck with a Software Engineering Institute process like PSP categorize testing as failure time and something to be minimized if not avoided. Cleanroom developers are taught that unit testing inteferes with metrics for quality, and that verifications are what should be done. Should such developers redo verifications after each refactoring? There's no answer in this book. An unusual chapter, called "Bad Smells in Code," gives overall motivation for the refactorings. These vague notions, such as "long methods" or "lazy classes" humorously provide a foundation for starting your own refactorings. I say "humorously" because (mostly) Beck's and Fowler's odd analogies (classes becoming too intimate and delving in each others' private parts) provoke a chuckle (as if a chapter about "bad smells" in code weren't enough). Overall, I've enjoyed reading this book and referring to the catalog while putting my own unit tests and refactorings into practice. Fowler's writing style is smooth and fluid, and it's easy to digest the catalog in no time. The book's typesetting is crisp, the figures quite clean, and both the refactoring index and "smell" index are enormously useful.
Refactoring: Improving the Design of Existing Code November 12, 2002 90 out of 97 found this review helpful
A little while back I was introduced to a word I had never heard before, Refactoring. I was told to get Martin Fowler's book and read it so I could gain a better understanding of what Refactoring was. Well folks, I would classify this book as a 'Hidden Treasure'. Although it is not a flashy or well known title, I believe its impact can be much deeper and long lasting than many of the mainstream, more popular technology books. The underlying theories that it teaches can be applied for years, even when languages change. There are only a couple of things I would change about this book, which I will mention below. Preface The Preface it brief enough, and gives the definition for the word Refactoring. This is a good thing because right form the start you get the true definition of Refactoring. In short, refactoring is the process of changing code to improve the internal structure, but not changing the external behavior. Chapter 1: Refactoring, a First Example In this chapter Mr. Fowler tries to start by showing a simple Refactoring example. The problem is that the chapter then goes on for 50+ pages. Mr. Fowler explains his reasons for doing this, but I think that a simple example should have been much simpler. Especially when it is in the first chapter of the book. It's not that this isn't a good chapter. I feel it's just too soon in the book. I would have put it at the end. Chapter 2: Principles of Refactoring This is an excellent chapter. The definition of Refactoring is discussed as well as the following questions: Why should you refactor? When should you refactor? What do I tell my manager? This last question may seem funny, but when you read this chapter you will understand why it is in there. This chapter also discusses common problems that occur during Refactoring, and Refactoring and performance. Chapter 3: Bad Smells in Code In this chapter things that cause code to 'smell' are discussed. When code 'smells' it could be an indicator that refactoring is needed. 22 different 'smells' are discussed. My favorites were Duplicated Code, Large Class, and Lazy Class. This is a chapter full of awesome hints. Chapter 4: Building Tests Building tests is an important part refactoring. Refactoring is done in small steps, and after every step you should test. In this chapter the discussion covers the processes and methodology of applying tests during refactoring. Chapter 5: Toward a Catalog of Refactorings This chapter is a quick setup for chapters 6 to 12. Mr. Fowler explains his method for cataloging the individual refactorings. What is pretty amazing is that he has taken a lot of time naming and detailing each refactoring. Chapter 6: Composing Methods One of my favorite chapters. Mr. Fowler opens by saying, "A large part of my refactoring is composing methods to package code properly." This chapter is all about that. 9 total refactorings are explained. My favorite ones are Inline Method and Extract Method. Chapter 7: Moving Features Between Objects Sometimes you need to move things from one object to another. This chapter discusses the art of moving features between objects. 8 total refactorings are discussed and detailed. My favorite from this chapter is Extract Class. Chapter 8: Organizing Data A very large chapter that discusses in meticulous detail 16 refactorings that will make it much easier to work with data. One thing that becomes very obvious in this chapter is that certain refactorings can go either way. What I mean is illustrated by these two: Change Value to Reference and Change Reference to Value. So some refactorings are not just one way deals. It just depends on the situation. Chapter 9: Simplifying Conditional Expressions This is a very useful chapter since conditional logic is a common occurrence in the programming world. Because conditional logic has a tendency to get very complex, this chapter has 8 refactorings that will help you simplify things. Chapter 10: Making Method Calls Simpler The 15 refactorings in this chapter help teach us how to make method calls easier to deal with. They range from the very simple Rename Method to the more complex Replace Constructor with Factory Method. Chapter 11: Dealing with Generalization Here are 12 refactorings dealing with the situations that arise from generalization. Inheritance, Delegation, and Interfaces are some of the topics discussed. Chapter 12: Big Refactorings Kent Beck co-wrote this chapter with Mr. Fowler. They discuss what they call the 4 Big Refactorings: Tease Apart Inheritance, Convert Procedural Design to Objects, Separate Domain from Presentation, and Extract Hierarchy. These refactorings are of a more all-encompassing type than the smaller individual refactorings from the preceding chapters. The co-authors do a great job at putting in a nutshell what would normally take very long explanations. Chapter 13: Refactoring, Reuse, and Reality William Opdyke writes this chapter. He discusses his experiences with refactoring as well as other subjects like why developers are reluctant to refactor and reducing the overhead of refactoring. This chapter is an excellent 'putting it all together' chapter, and really helps put into perspective the ideas that the book teaches. Chapter 14: Refactoring Tools Don Roberts and John Brant co-author this chapter. They discuss, as the chapter title would indicate, refactoring tools. Chapter 15: Putting It All Together Kent Beck gives a quick 4-page wrap up. One other thing I would change about the book is that I would want there to be examples in other languages besides Java. I have practically no Java skills. For me the book would have been an easier and faster read if it would have had examples in VB.net. Fortunately I understand enough to get the idea of what is being taught, and that is the most important point. Well as I said above, this book is really what I would consider a 'hidden treasure'. The things discussed will help many people write better, more understandable code for years to come. I would give it a 9.5 out of 10. It is well worth the {price}
Good Information But Extremely Poor Delivery March 15, 2000 50 out of 62 found this review helpful
This book contains some good information on how to improve yourexisting code without rewriting it entirely which is a nice departurefrom the norm of most of these UML-type books which advocate totally changing the way you design and build software. Not that the Unified method of designing and building is bad, its just that its hard to change the way this is done in an organization when you're not in charge of the organization. Mr. Fowler has put forth a mechanism for improving the design of existing code while adding functionality to it. And the information, once culled from the surrounding text, is extremely useful. It's not paradigm shift. And it's not a companion to Design Patterns - Fowler mentions the Design Patterns book throughout his text but this book is certainly not written for the same audience. Fowler never once gives an example where he converts bad code into good by utilizing a pattern from the Gang of Four's book. The book is useful for ANY object-oriented language even though he uses Java in his examples the principles map easily to C++ and SmallTalk. Almost all of the techniques are common sense and yet he spends the bulk of this book explaining in simple terms how to perform them. For each "refactoring" he capably provided a two or three sentence overview of the process, and a code fragment or class diagram exemplifying the technique. These summaries and figures are excellent. But his tone becomes condescending as he painfully explains the process of performing the code improvement. For instance, Extract Method, the first technique in the book, is succinctly described with: "[If] You have a code fragment that can be grouped together...[then] Turn the fragment into a method whose name explains the purpose of the method." Pretty simple and probably not quite enough to totally understand what he is talking about. But then he has a wonderful little code fragment that illustrates it perfectly. This requires about half of one page. But he spends four and a half more explaining how to perform this simple cut-and-paste. 270 Pages of this 418 page book are spent describing 72 techniques in this kind of excruciating detail. Eight very useful pages are spent describing the bad "smells" in your code that lead to these "refactactorings". Another 110 pages is spent telling you how to justify the work to your boss, encouraging you to do it whether or not your boss approves, advocating a "test-small-change-test" paired programming technique characteristic of Extreme Programming. The final 30 pages are written by the other contributors. Altogether, I think this book should be "refactored" into a 100 to 150 page soft-cover manual reminiscent of Scott Meyers' Effective C++ books. If you're looking for Design Patterns: Part 2 this isn't it! END
Don't just read it - buy it July 19, 2000 37 out of 39 found this review helpful
One can read good books on a specific technology (COM, UML etc) or on specific programming languages or even on different approaches to software development (RUP, OPEN etc) but every now and then a true classic comes along. Like Design Patterns 4 years ago now refactoring comes along. Every serious OO developer should own both of these books. Get your hands on Refactoring if only to read chapter 3, which summarises all the 'bad smells' that may creep into code. 21 generic examples of what is bad programming and why. The remainder of the book describes numerous techniques (refactorings) for changing existing code in order to remove the 'smell'. Most refactorings are accompanied with some UML, which should be enough to get the idea, and they are then further described in Java. What makes this great a book is that it can be used as a reference very easily since its design was well thought out for this purpose with a comprehensive index and tables matching smells and respective refactorings. If any of this rings a bell to CODE COMPLETE readers it should cause the ideas are very similar but very much updated here. Fowler's writing style makes once again for easy, pleasant reading. Unreservedly recommended.
Making tired old code better May 17, 2000 24 out of 24 found this review helpful
The basic thesis of this book is that, for various reasons, real programs are poorly designed. They get that way for a variety of reasons. Initially well designed, extending the program may lead to software decay. Huge methods may result from unanticipated complexity. Refactoring, according to Fowler, is a function preserving transformation of a program. The transformations are reversible, so the intention is to improve the program in some way.Fowler suggests refactoring a program to simplify the addition of new functionality. The program should also be refactored to make it easier for human readers to understand at the same time. He also insists that each step is small and preserves functionality, and on frequent unit testing with a comprehensive test suite. Half of the book consists of a catalogue of refactorings. He gives each refactoring a memorable name, such as "Replace Type Code with Subclasses". He illustrates the design transformation with a pair of UML class diagrams, and has a standard set of sections: Motivation, Mechanics and Example. The Motivation is a prose section that describes and justifies the refactoring, showing the relationship to other refactorings. The Mechanics is a sequence of steps needed to carry out the refactoring, shown as a list of bullet points He expands on some points. The Example is where the value of this book lies. Fowler takes a fragment of Java code, and takes us step by step through the refactoring. The code is small enough that he can show it all each step of the way without overwhelming us, but is large enough to be realistic. The code is clear enough for non-Java programmers to follow. He explains his code well enough for the book to function as a Java tutorial where the meaning of the code is not obvious. One or two of the refactorings are specific to the Java object model, and do not apply to other languages. Other languages would benefit from similar treatment, but there are very few language-specific refactorings. The book is very much of the Design Patterns movement, with frequent references to patterns. The aim of a factoring may be to achieve a particular pattern, or it may take advantage of a particular pattern. The book can be used as a tutorial on Design Patterns. I have a small number of complaints. Fowler advocates the use of refactoring while studying code for a code review. One needs to be very sensitive to the feelings of the programmer here, especially if he or she is a novice. The reviewer should read the code with refactoring in mind, and possible refactorings recommended, but it is for the programmer to make the changes. Reading this book has inspired me to refactor some of my own code. My mistakes underlined the need to take small steps, and to test frequently. I spent a day building a useful Delphi testing framework from the description Fowler gives of the JUnit testing framework. The one category of code that does not seem to lend itself to this approach is some highly coupled parsing code. While I can extract small blocks of code, they remain tightly coupled with each other, and it is hard to give them meaningful names. The answer here may be to use the top down approach of recursive descent, rather than the bottom up approach of refactoring. Perhaps recursive descent can guide refactoring. Refactoring is largely a local approach. One can almost say a pinhole approach. Sometimes a global view is needed. In summary, I would say that this very good book would be of use to Java programmers who have some understanding and much bafflement. It is very good for us older dogs who have become a little jaded and need some new ideas and motivation.
|
|
| Powered by Associate-O-Matic
| |