Prefactoring by Ken Pugh …
Thursday, October 25th, 2007I started software development 23 years ago and in those first couple of years I worked with a guy who used to say “The quickest way to do anything is not to have to do it.”, and this is why you should get the book “Prefactoring by Ken Pugh, Copyright 2005 O’Reilly Media Inc., 0-596-00874-0. That guy used to also say “bugger all of bugger all is still bugger all”, but that isn’t covered in the book so I’ll stick with the first saying.
There is a lot of buzz around Refactoring and how to improve software that is already written, but Prefactoring is a collection of guidelines that help you make better software the first time around. The guidelines won’t remove your need to refactor, but they will have made it easier to do when the time comes. Having a copy of Prefactoring is like having a senior software developer pairing with you all the time.
You should buy the Prefactoring book because it collects together in one place many guidelines that help you write better software. The explanations for the guidelines are clear and the guidelines themselves are well presented. Close to each guideline is an exert box containing some text that helps to explain the “why” of the guidelines. There wasn’t a guideline that was new to me, but the way they are presented will make it much easier for me to explain “why” to other team members when I suggest they take a different approach to their code.
What follows is the list of guidelines to give you an idea what is covered. This list is no substitute for getting the book since you miss out on the “why” for each guideline. Maybe later I’ll expand this list with the additional sentences that go with each guideline, if enough people ask for it.
- A Rose by Any Other Name Is Not a Rose
- Adapt a Prefactoring Attitude
- Adopt And Adapt
- Avoid Premature Generalization
- Avoid Premature Inheritance
- Be Ready to Import and Export
- Build Flexibility for Testing
- Business Rules Are a Business unto Themselves
- Clump Data so That There Is Less to Think About
- Communicate With Your Code
- Consider Failure and Expectation, Not an Exception
- Consider Privacy
- Consistency Is Simplicity
- Create Interface Contracts
- Decide on a Strategy to Deal with Deviations and Errors
- Declaration over Execution
- Decouple with Associations
- Do a Little and Pass The Buck
- Do a Little Job Well and You Will Be Called upon Often
- Document Your Assumptions and Your Decisions
- Don’t Change What It Is
- Don’t Let The Cold Air In
- Don’t Overclassify
- Don’t Reinvent the Wheel
- Don’t Repeat Yourself (DRY)
- Don’t Speed Until You Know Where You Are Going
- Exceptional Guideline
- Explicitness Beats Implicitness
- Figure Out How to Migrate Before You Migrate
- Get Something Working
- If It Can’t Be Tested, Don’t Require it
- If It Has Collection Operations, Make It a Collection
- If You Forget Security, Your Not Secure
- Honor The Class Maxims
- Know Who It Is
- More Is Sometimes Less
- Most Strings Are more than just a String
- Never Be Silent
- Never Let a Constant Slip into Code
- Nothing Is Perfect
- Overloading Functions Can Become Overloading
- Perform Retrospectives After Each Release
- Place Methods In Classes Based on What They Need
- Plan for Testing
- Plan Globally, Develop Locally
- Plan Your Logging Strategy
- Prototypes Are Worth A Thousand Words
- Report Meaningful User Messages
- See What Condition Your Condition Is In
- Separate Concerns to Make Smaller Concerns
- Separate Policy From Implementation
- Split Interfaces
- Splitters Can Be Lumped More Easily Than Lumpers Can Be Split
- Test or Production: That Is The Question
- Test the Interface, Not the Implementation
- The Easiest Code to Debug Is That Which Is Not Written
- The Spreadsheet Conundrum
- Think About The Big Picture
- Think Interface, Not Inheritance
- To Test or Not to Text
- Use the Client’s Language
- Use the Same Layout to Get the Same Layout
- Validate, Validate, Validate
- When in Doubt, Indirect
- When You’re Abstract, be Abstract All the Way