Publisher: Pearson Education (US)
Isbn-10: 0201485672 | Isbn-13: 9780201485677 | Publish date: 28/06/1999 | Edition 1st
Also available as: eBook
Do you like Refactoring ?
Join aNobii to see if your friends read it, and discover similar books!
Aecho said on Dec 17, 2014, 07:22
Refactoring is the process of rewriting software, without changing the way it functions, in order to improve its readability, testability or maintanability. A book has been written on the subject by Martin Fowler. Some of the chapters were written by other people.
“Refactoring: Improving the Design of Existing Code” is focused on OO programming (lots of Java examples) and Agile practices. It is setup as a catalog of refactoring techniques. Each page dedicated to a refactoring is clearly marked, so that you can easily look up a refactoring.
The book was written a decade ago. At that time IDE’s did not support advanced refactorings. Most of the methods described are fully automated in modern IDE’s. This means that you don’t have to follow the text that closely any more.
The first chapter starts with a simple example. Java code is used throughout the example as well as UML diagrams.
2. Principles in Refactoring
The Why and When of refactoring are discussed. Also we get instructions on what to tell our manager about refactoring. This seems a bit silly to me, since I have never had to explain refactoring to my managers.
3. Bad Smells in Code
“Code Smells” is a frequently used Agile phrase. A phrase I don’t care that much about. Code works or it doesn’t, it can be ugly or unreadable, but it doesn’t smell. The list of “smells” makes sense, however some of the names are downright confusing. For instance, would you be able to tell me what “Refused Bequest” means?
4. Building Tests
This chapter talks about JUnit at length. I am sure you are aware that there are many other unit testing frameworks for programming languages other than Java such as PyUnit. We are told that before you start refactoring, you need to have tests. I think it is more of a chicken/egg dilemma. Sometimes you need to refactor first in order to test. Unit tests and functional tests are mentioned. Integration tests, however are completely ignored. How would you know whether the performance and memory usage of your system remained the same? Clearly, this chapter was written by a software developer, and not by somebody who likes breaking applications, I mean testing applications.
5. Toward a Catalog of Refactorings
Chapter 5 describes the catalog of refactorings to follow. It is the catalog metada in a sense.
6. Composing methods
This chapter is the beginning of the catalog, which forms the “meat” of the book. I am just going to mention a few of the techniques listed in chapter 6.”Extract Method” is one of those refactorings I use on a daily basis. Sometimes things go wrong so we have to do the opposite refactoring “Inline Method”. The author starts using the term “temp” to mean temporary local variables.
7. Moving Features Between Objects
The author admits that he has trouble assigning responsibilities to objects. We are supposed to fix errors with “Move Method”, “Move Field”, “Extract Class” or other refactorings in this chapter.
8. Organizing Data
This chapter discusses a lot of different ways to simplify working with data. For instance, with these refactorings:
Replace Data Value with Object
Replace Array with Object
Also the refactoring “Replace Magic Number with Symbolic Constant” is explained a.k.a “Extract Constant”.
9. Simplifying Conditional Expressions
In my opinion the refactorings in this chapter need to be renamed. Apart from “Decompose Conditional”, which is clear enough. Although “Breaking up Conditional” might have been better.
10. Making Method Calls Simpler
Make method calls simpler by renaming them or replacing long parameter lists by objects. The latter technique could be a problem in concurrent programs. It is common to pass immutable values as parameters. You might not be able to replace them by immutable objects.
11. Dealing with Generalization
Generalization or in OO terms inheritance is a powerful mechanism, that tends to be overused a lot. You can push/pull a method or a field. Inheritance can be replaced by delegation and vice versa.
12. Big Refactorings
In this chapter starts what we can call the “dessert” part. No more simple refactoring recipes. Instead four refactorings that take a considerable amount of time.
13. Refactoring, Reuse and Reality
This chapter is an essay on Refactoring by William Opdyke.
14. Refactoring Tools
IDE’s have come a long way since this book was written. Most of the issues in this chapter are no longer valid.
15. Putting It All Together
This final chapter by Kent Beck is a bit mystical and vague. Those are his own words by the way. Some of the points make sense, but the chapter is written too much in a master talking to an apprentice style.
The book has a list of soundbites at the end. Literally. The fun thing is that you probably have heard or are going to hear a lot of these soundbites. “Refactoring” is a very useful book, albeit too focused on Java. Most recipes would work for another Object Oriented language. I give this book 5 stars out of 5.
Ivan Idris said on Jan 22, 2012, 11:36
lyhcode said on Aug 26, 2011, 14:27
這本書裡面除了解釋什麼是 Refactoring 意義之外，包含了幾個重要概念以及些程式設計上的技巧與試用時機。而且概念搭配適用時機，再加上程式碼對照看，學習起來變容易。
Edward Chiang said on Jan 14, 2011, 02:56
miguelff said on Oct 05, 2010, 14:52
Reinhard said on Oct 04, 2010, 12:40
Una pietra miliare per chiunque sviluppi software.
Mai letto un libro che sia riuscito a darmi tanto in cosi tanto poco (citazione di una frase di Churchill ;))
La sua spettacolarità la manifesta proprio nella capacità di concretizzare istantaneamente i consigli che vengono riportati.
Ha stravolto il mio modo di pensare al software...non avevo mai letto niente riguardo al refactoring e prima di questo libro neanche conoscevo il termine. Ha creato un nuovo punto di vista da cui osservare lo sviluppo del software...un nuovo cardine su cui far ruotare la creazione.
Fantastico...senza mezzi termini...fantastico!
DAXweb said on Sep 19, 2010, 06:01
I wish I've got ahold of Refactoring Ruby Edition before of Refactoring because the content is the same and I'd rather have read it with Ruby code.
The book was quite interesting but I've felt it didn't provided much new to me. I suppose I always considered refactoring part of programming and that I inferred how to do it by playing with the advance Java refactoring tools we have today. If I've read this book when it appeared it probably would have been revolutionary.
If you don't know what refactoring is, how to do it, when to do it, then this book is for you.
J. Pablo Fernández said on Apr 06, 2010, 11:05
asterixcapri said on Jan 06, 2010, 12:32
The First thing: although it is dated - out of date - I think it is a good book to consult.
The Second: A practical guide for those wishing to learn more about software design and development; I think It is recommended for all people that work in a development team and who want to learn the basic of obìject oriented programming. It is also useful for who want to improve their productivity.
luca said on Dec 09, 2009, 14:36