You are previewing Prefactoring.
O'Reilly logo
Prefactoring

Book Description

Prefactoring approaches software development of new systems using lessons learned from many developers over the years. It is a compendium of ideas gained from retrospectives on what went right and what went wrong in development. Some of these ideas came from experience in refactoring. Refactoring is improving the design of existing code to make it simpler and easier to maintain.

This practical, thought-provoking guide details prefactoring guidelines in design, code, and testing. These guidelines can help you create more readable and maintainable code in your next project.

To help communicate the many facets of this approach, Prefactoring follows the development of a software system for a fictitious client, named Sam, from vision through implementation. Some of the guidelines you'll encounter along the way include:

  • When You're Abstract, Be Abstract All the Way

  • Splitters Can Be Lumped Easier Than Lumpers Can Be Split

  • Do a Little Job Well and You May Be Called Upon Often

  • Plan Globally, Develop Locally

  • Communicate with Your Code

  • The Easiest Code to Debug Is That Which is Not Written

  • Use the Client's Language

  • Don't Let the Cold Air In

  • Never Be Silent

  • Don't Speed Until You Know Where You Are Going

Table of Contents

  1. Copyright
  2. Dedication
  3. Preface
    1. Everybody Is Different
    2. The Design Example
    3. Audience
    4. Contents of This Book
    5. The Cover
    6. Conventions Used in This Book
    7. Using Code Examples
    8. Comments and Questions
    9. Safari Enabled
    10. Acknowledgments
  4. Introduction to Prefactoring
    1. What Is Prefactoring?
    2. The Three Extremes
    3. The Guidelines Explored
    4. The Context for This Book
  5. The System in So Many Words
    1. Meet Sam
    2. Reinvention Avoidance
    3. What's in a Name?
    4. Splitters Versus Lumpers
    5. Clumping
    6. Abstracting
    7. Prototypes Are Worth a Thousand Words
  6. General Development Issues
    1. Start with the Big Picture
    2. Interface Contracts
    3. Validation
    4. Code Communicates
    5. Consistency Is Simplicity
    6. A Prefactoring Attitude
    7. Don't Repeat Yourself
    8. Documentation of Assumptions and Decisions
    9. Dealing with Deviations and Errors
    10. Speeding
    11. The Spreadsheet Conundrum
    12. Tools Are Tools—Use Them Wisely
  7. Getting the Big Picture
    1. The Rest of the Story
    2. Process
    3. The Initial Design
    4. Global Planning, Local Designing
    5. Testing Functionality
    6. Testing Quality
    7. Security
  8. Got Class?
    1. Categories and Classes
    2. Declaration Versus Execution
    3. Appropriate Inheritance
    4. Communicate with Text
    5. More Than One
  9. A Few Words on Classes
    1. Honor the Class Maxims
    2. Three Laws of Objects
    3. Need Determines Class
    4. Polymorphism
    5. One Little Job
    6. Policy Versus Implementation
    7. Extreme Naming
    8. Overloading Functions
  10. Getting There
    1. Where We Are
    2. Separating Concerns
    3. Migrating to the New System
  11. The First Release
    1. The Proof Is in the Pudding
    2. Retrospective Time
    3. The System as It Stands Now
    4. Operations Interface
    5. Abstract Data Types
    6. Configuration
    7. Testing
    8. Dealing with Deviations and Errors
    9. A Little Prefactoring
    10. The First Released Iteration
    11. Sometimes Practice Does Not Match Theory
    12. The Rest of the Classes
  12. Associations and States
    1. Sam's New Requirement
    2. Who's in Charge?
    3. The State of an Object
  13. Interfaces and Adaptation
    1. The Catalog Search Use Case
    2. Designing the Interface
    3. Interface Development
    4. Interface Testing
    5. Interface Splitting
    6. Something Working
  14. Zip Codes and Interfaces
    1. Adaptation
    2. Pass the Buck
    3. Unwritten Code
    4. Indirection
    5. Logging
    6. Paradigm Mismatch
  15. More Reports
    1. Fancy Reports
    2. Change Happens
    3. Exports
  16. Invoices, Credit Cards, and Discounts
    1. The Next Step
    2. The Language of the Client
    3. Security and Privacy
  17. Sam Is Expanding
    1. The Second Store
    2. A New Development
    3. The Third Store
    4. Goodbye Sam
    5. Generality
  18. A Printserver Example
    1. Introduction
    2. The System
    3. The Message
    4. Testing
    5. Logging
    6. Still More Separation
    7. Epilogue
  19. Antispam Example
    1. The Context
    2. Spam Checking
    3. The ReceivingMailServer
    4. ReceivedMailExaminer
    5. The Full Flow
  20. Epilogue
  21. Guidelines and Principles
    1. Guidelines
    2. Guidelines in Alphabetical Order
    3. Software Design Principles
  22. Source Code
    1. com.samscdrental.configuration Package
    2. com.samscdrental.controller Package
    3. com.samscdrental.dataaccess Package
    4. com.samscdrental.display.adt Package
    5. com.samscdrental.display Package
    6. com.samscdrental.failures Package
    7. com.samscdrental.helper Package
    8. com.samscdrental.importexport Package
    9. com.samscdrental.migration Package
    10. com.samscdrental.model.adt Package
    11. com.samscdrental.model.dto Package
    12. com.samscdrental.model Package
    13. com.samscdrental.reports Package
    14. com.samscdrental.tests Package
  23. Colophon
    1. About the Author
    2. Colophon
  24. Index