Although I bought refactoring book by Martin Fowler years ago it is still valid. I call it one of the timeless books about coding and I consider it as a mandatory reading specially for novice programmers who are entering the field. Of course it is also useful handbook for those already in business. This refactoring book covers and organizes most of changes we are doing to source code every day and it greatly helps us to understand the nature of those changes at crafting level.
Why consider refactoring book?
This book by Martin Fowler is something that serious developers should read when learning hardcore coding. Big part of our actual coding work is improving existing code and this is what this book is about. It organizes our most important code changing activities and describes these in detail.
Some developers may ask – why to describe what we are doing everyday if we are learned how to do our job? Well, the knowledge in this book comes from practice and not from theory. I went through this book years ago when I already had been in coding around ten years and this book still had many tricks to offer plus some many details to get me to better understanding about changes in code.
In my opinion this book is worth buying as hardcover paper book because it is useful as long as coding has not changed to something totally different from what it is now.
Table of contents
- Refactoring, a First Example
- Principles in Refactoring
- Bad Smells in Code
- Building Tests
- Toward a Catalog of Refactorings
- Composing Methods
- Moving Features Between Objects
- Organizing Data
- Simplifying Conditional Expressions
- Making Method Calls Simpler
- Dealing with Generalization
- Big Refactorings
- Refactoring, Reuse, and Reality
- Refactoring Tools
- Putting It All Together
List of Soundbites
Refactorings covered in this book
Composing Methods: Extract method, Inline Method, Inline Temp, Replace Temp with Query, Introduce Explaining Variable, Split Temporary Variable, Remove Assignment to Parameters, Replace Method with Method Object, Substitute Algorithm.
Moving Features Between Objects: Move Method, Move Field, Extract Class, Inline Class, Hide Delegate, Remove Middle Man, Introduce Foreign Method, Introduce Local Extension.
Organizing Data: Self Encapsulate Field, Replace Data Value with Object, Change Value to Reference, Change Reference to Value, Replace Array with Object, Duplicate Observed Data, Change Unidirectional Association to Bidirectional, Change Bidirectional Association to Unidirectional, Replace Magic Number with Symbolic Constant, Encapsulate Field, Encapsulate Collection, Replace Recod with Data Class, Replace Type Code with Class, Replace Type Code with Subclasses, Replace Type Code with State/Strategy.
SImplifying Conditional Expressions: Decompose conditional, Consolidate Conditional Expression, Consolidate Duplicate Conditional Fragments, Remove Control Flag, Replace Nested Conditional with Guard Clauses. Replace Conditional with Polymorphism, Introduce Null Object, Introduce Assertion.
Making Method Calls Simpler: Rename Method, Add Parameter, Remove Parameter, Separate Query from Modifier, Parameterize Method, Replace Parameter with Explicit Methods, Preserve Whole Object, Replace Parameter With Method, Introduce Parameter Object, Remove Setting Method, Hide Method, Replace Constructor with Factory Method, Encapsulate Downcast, Replace Error Code with Exception, Replace Exception with Test.
Dealing with Generalization: Pull Up Field, Pull Up Method, Pull Up Constructor Body, Push Down Method, Push Down Field, Extract Subclass, Extract Superclass, Extract Interface, Collapse Hierarchy, Form Template Method, Replace Inheritance with Delegation, Replace Delegation with Inheritance.