Contents

Series Foreword

Preface

Acknowledgments

About the Authors

Part I The Core Trim Tabs

Chapter 1 Programming by Intention

Programming by Intention: A Demonstration

Advantages

Method Cohesion

Readability and Expressiveness

Debugging

Refactoring and Enhancing

Unit Testing

Easier to Modify/Extend

Seeing Patterns in Your Code

Movable Methods

Summary

Chapter 2 Separate Use from Construction

An Important Question to Ask

Perspectives

Perspective of Creation

Perspective of Use

What You Hide You Can Change

Realistic Approach

Other Practical Considerations

Timing Your Decisions

Overloading and C++

Validating This for Yourself

Summary

Chapter 3 Define Tests Up Front

A Trim Tab: Testing and Testability

What Is Testing?

Testability and Code Quality

Case Study: Testability

Setting Ourselves Up for Change

Programmer as Frog

A Reflection on Up-Front Testing

Better Design

Improving Clarity of Scope: Avoiding Excess Work

Reducing Complexity

Other Advantages

No Excuses

Summary

Chapter 4 Shalloway’s Law and Shalloway’s Principle

Types of Redundancy

Copy and Paste

Magic Numbers

Other Types

Redefining Redundancy

Other Types of Redundancy

The Role of Design Patterns in Reducing Redundancy

Few Developers Spend a Lot of Time Fixing Bugs

Redundancy and Other Code Qualities

Summary

Chapter 5 Encapsulate That!

Unencapsulated Code: The Sabotage of the Global Variable

Encapsulation of Member Identity

Self-Encapsulating Members

Preventing Changes

The Difficulty of Encapsulating Reference Objects

Breaking Encapsulation with Get()

Encapsulation of Object Type

Encapsulation of Design

Encapsulation on All Levels

Practical Advice: Encapsulate Your Impediments

Summary

Chapter 6 Interface-Oriented Design

Design to Interfaces

Definition of Interface

Interface Contracts

Separating Perspectives

Mock Implementations of Interfaces

Keep Interfaces Simple

Avoids Premature Hierarchies

Interfaces and Abstract Classes

Dependency Inversion Principle

Polymorphism in General

Not for Every Class

Summary

Chapter 7 Acceptance Test–Driven Development (ATDD)

Two Flows for Development

Acceptance Tests

An Example Test

Implementing the Acceptance Tests

User Interface Test Script

User Interface for Testing

XUnit Testing

Acceptance Test Framework

Connection

An Exercise

What to Do If the Customer Won’t Tell You

Summary

Part II General Attitudes

Chapter 8 Avoid Over- and Under-Design

A Mantra for Development

The Pathologies of Code Qualities

Avoid Over- and Under-Design

Minimize Complexity and Rework

Never Make Your Code Worse/Only Degrade Your Code Intentionally

Keep Your Code Easy to Change, Robust, and Safe to Change

A Strategy for Writing Modifiable Code in a Non-Object-Oriented or Legacy System

Summary

Chapter 9 Continuous Integration

Branching the Source Code

Multiple Versions: Specialization Branching

Working in Isolation: Development Branching

Problem, Solution, Problem

The Merge-Back

Test-Driven Development and Merge Cost

Continuous Integration

Continuous Integration Servers

Summary

Part III Design Issues

Chapter 10 Commonality and Variability Analysis

Using Nouns and Verbs as a Guide: Warning, Danger Ahead!

What Is the Real Problem?

What We Need to Know

Handling Variation

Commonality and Variability Analysis

Commonality Analysis

Variability Analysis

Object-Oriented Design Captures All Three Perspectives

A New Paradigm for Finding Objects

Tips for Finding Your Concepts and Variations with an Example

The Analysis Matrix: A Case Study

Selecting the Stories to Analyze

Summary

Chapter 11 Refactor to the Open-Closed

The Open-Closed Principle

Open-Closed to Other Things

Open-Closed Is a “Principle”

Refactoring

Why Refactor?

Debt versus Investment

Refactoring and Legacy Systems

Refactoring to the Open-Closed

Just-in-Time Design

Summary

Chapter 12 Needs versus Capabilities Interfaces

The Law of Demeter

Coupling, Damned Coupling, and Dependencies

Coupling and Testability

Needs versus Capabilities

The Ideal Separation: Needs Interfaces and Capabilities Interfaces

Back to the Law of Demeter

Summary

Chapter 13 When and How to Use Inheritance

The Gang of Four

Initial Vectors, Eventual Results

Favoring Delegation

The Use of Inheritance versus Delegation

Uses of Inheritance

Scalability

Applying the Lessons from the Gang of Four to Agile Development

Testing Issues

There’s More

Part IV Appendixes

Appendix A Overview of the Unified Modeling Language (UML)

What Is the UML?

Why Use the UML?

The Class Diagram

UML Notation for Access

Class Diagrams Also Show Relationships

Showing the “has-a” Relationship

Composition and Uses

Composition versus Aggregation

Notes in the UML

Indicating the Number of Things Another Object Has

Dashes Show Dependence

Sequence Diagram

Object:Class Notation

Summary

Appendix B Code Qualities

Christmas-Tree Lights: An Analogy

Cohesion

Description

Principles

Practices

Pathologies

Indications in Testing

Coupling

Description

Principles

Practices

Pathologies

Indications in Testing

Redundancy

Description

Principles

Practices

Pathologies

Indications in Testing

Encapsulation

Description

Principles

Practices

Pathologies

Indications in Testing

Appendix C Encapsulating Primitives

Encapsulating Primitives in Abstract Data Types

Principles

Narrow the Contract

Expanding Abstract Data Types

Use Text as External Values

Enumerations Instead of Magic Values

Disadvantages

Summary

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.234.225