Agile Software Development

Similar documents
Agile Principles, Patterns, and Practices in C#

Designing Object-Oriented C++ Applications

Software Engineering

OO Package Design Principles

Summary of the course lectures

SOLID Principles. Equuleus Technologies. Optional Subheading October 19, 2016

Ingegneria del Software Corso di Laurea in Informatica per il Management. Software quality and Object Oriented Principles

CHAPTER 5: PRINCIPLES OF DETAILED DESIGN

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

Object-Oriented Design

The Design Patterns Matrix From Analysis to Implementation

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

The Release Reuse Equivalency Principle (REP) The Common Closure Principle (CCP) The Common Reuse Principle (CRP)

Object-Oriented Design

Outline. Software Rots

COURSE 2 DESIGN PATTERNS

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

CSC207H: Software Design SOLID. CSC207 Winter 2018

(Movement - Synthesis) Improve existing programming skills by developing much larger and more complex programs than in previous classes.

Principles of OO Design

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

Single Responsibility Principle (SRP)

Index. Dmitri Nesteruk 2018 D. Nesteruk, Design Patterns in Modern C++,

Software Design and SOLID Principles

17.11 Bean Rules persistent

CSE 70 Final Exam Fall 2009

Influence of Design Patterns Application on Quality of IT Solutions

Component-Level Design. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman. For non-profit educational use only

Conception Orientée Objets. Programmation SOLID

Principles of Object-Oriented Design

Produced by. Agile Software Development. Eamonn de Leastar

UML and Design Patterns Prof. Dr. Eric Dubuis, V. June Engineering and Information Technology. On Package Design

SOLID: Principles of OOD

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

Object design. François Schwarzentruber ENS Cachan Antenne de Bretagne

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

OO Class Design Principles

Agile Architecture. The Why, the What and the How

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

09. Component-Level Design

Review Software Engineering October, 7, Adrian Iftene

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Introduction to Software Engineering: Object Design I Reuse & Patterns

Object-oriented design principles

Top Down Design vs. Modularization

Objects First with Java

Granularity. Inheritance Bi-directional. Association. Derived A1

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Introduction to Testing and Maintainable code

5 Object Oriented Analysis

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Foundations of object orientation

Open Closed Principle (OCP)

Basic design patterns

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Object-oriented Software Design Patterns

Composite Pattern. IV.4 Structural Pattern

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Kerievsky_book.fm Page 355 Thursday, July 8, :12 PM. Index

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

Object design. François Schwarzentruber ENS Cachan Antenne de Bretagne

S.O.L.I.D: Software Engineering Principles

"Charting the Course... Agile Database Design Techniques Course Summary

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Design patterns. Jef De Smedt Beta VZW

20 Years of. Improve the Design of your Code. Dr Dimitris Dranidis JAVA Meetup Group, Thessaloniki May 2015

How Can a Tester Cope With the Fast Paced Iterative/Incremental Process?

Index Shalloway rev.qrk 9/21/04 5:54 PM Page 419. Index

CS485/540 Software Engineering Architecture and Component Design (Chs. 9,10)

SDC Design patterns GoF

Component-Level Design

S.O.L.I.D. Principles of

Introduction to Object-Oriented Programming

Overview CS Kinds of Patterns. Design Pattern. Factory Pattern Rationale. Kinds of Factory Patterns

XP Evolution Rachel Davies

Unit Wise Questions. Unit-1 Concepts

PYTHON. p ykos vtawynivis. Second eciitiovl. CO Ve, WESLEY J. CHUN

Object-Oriented Design

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO

Dependency Inversion Principle (DIP) Package Design: Coupling Principles

XP: Planning, coding and testing. Planning. Release planning. Release Planning. User stories. Release planning Step 1.

Design Patterns. Gunnar Gotshalks A4-1

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Study Guide to Exam 2

Principles of Object-Oriented Design

Exam in TDDB84: Design Patterns,

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Build Testable Client and Service Applications

OOD Smells and Principles

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

INTERNAL ASSESSMENT TEST III Answer Schema

A Rapid Overview of UML

Design Pattern and Software Architecture: IV. Design Pattern

Agile Model-Driven Development with UML 2.0 SCOTT W. AM BLER. Foreword by Randy Miller UNIFIED 1420 MODELING LANGUAGE. gile 1.

Stability. Introduction

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod

Transcription:

Agile Software Development Principles, Patterns, and Practices Robert Cecil Martin Alan Apt Series Prentice Hall Pearson Education, Inc. Upper Saddle River, New Jersey 07458

Foreword Preface About the Authors List of Design Patterns m iv ix xxii Section 1 Chapter 1 Chapter 2 Agile Development Agile Practices The Agile Alliance The Manifesto of the Agile Alliance Principles Overview of Extreme Programming The Practices of Extreme Programming Customer Team Member User Stories Short Cycles Acceptance Tests * Pair Programming Test-Driven Development Collective Ownership Continuous Integration Sustainable Pace Open Workspace Th'e Planning Game Simple Design Refactoring Metaphor 3 4 46 11 11 11 12 12 13 13 14 14 14 15 15 15 15 16 16 17 17

xiii Chapter 3 Chapter 4 Chapter 5 Chapter 6 Planning Initial Exploration Spiking, Splitting, and Velocity Release Planning Iteration Planning Task Planning The Halfway Point Iterating Testing Test Driven Development An Example of Test-First Design Test Isolation Serendipitous Decoupling Acceptance Tests Example of Acceptance Testing Serendipitous Architecture Refactoring Generating Primes: A Simple Example of Refactoring The Final Reread A Programming Episode The Bowling Game 19 20 20 20 21 21 22 22 22 22 23 23 24 25 26 27 27 29 29 29 31 32 38 42 42 43 44 82 Section 2 Agile Design 85 Chapter 7 Symptoms of Poor Design Principles Smells and Principles What Is Agile Design? What Goes Wrong with Software? Design Smells The Odors of Rotting Software What Stimulates the Software to Rot? Agile Teams Don't Allow the Software to Rot The "Copy" Program Agile Design of the Copy Example How Did the Agile Developers Know What to Do? Keeping the Design As Good As It Can Be 85 86 86 86 87 87 88 89 90 90 93 94 94 94 94

xiv Chapter 8 SRP: The Single-Responsibility Principle A CLASS SHOULD HAVE ONLY ONE REASON TO CHANGE. SRP: The Single-Responsibility Principle What Is a Responsibility? Separating Coupled Responsibilities Persistence Contents 95 95 97 97 98 98 98 Chapter 9 OCP: The Open-Closed Principle SOFTWARE ENTITIES (CLASSES, MODULES, FUNCTIONS, ETC.) SHOULD BE OPEN FOR EXTENSION, BUT CLOSED FOR MODIFICATION. OCP: The Open-Closed Principle Description Abstraction Is the Key The Shape Application Violating the OCP Conforming to the OCP OK, I Lied Anticipation and "Natural" Structure Putting the "Hooks" In Using Abstraction to Gain Explicit Closure Using a "Data-Driven" Approach to Achieve Closure Chapter 10 LSP: The Liskov Substitution Principle SUBTYPES MUST BE SUBSTITUTABLE FOR THEIR BASE TYPES. LSP: The Liskov Substitution Principle A Simple Example of a Violation of the LSP Square and Rectangle, a More Subtle Violation The Real Problem =" Validity Is Not Intrinsic ISA Is about Behavior Design by Contract Specifying Contracts in Unit Tests A Real Example Motivation Problem A Solution That Does Not Conform to the LSP An LSP-Compliant Solution Factoring Instead of Deriving Heuristics and Conventions Degenerate Functions in Derivatives Throwing Exceptions from Derivatives 99 99 100 100 101 101 103 104 105 105 106 107 108 109 111 111 112 113 115 116 116 117 117 117 118 119 120 120 121 124 124 124 125 125

Chapter 11 DIP: The Dependency-Inversion Principle A. HIGH-LEVEL MODULES SHOULD NOT DEPEND UPON LOW-LEVEL MODULES. BOTH SHOULD DEPEND ON ABSTRACTIONS. B. ABSTRACTIONS SHOULD NOT DEPEND ON DETAILS. DETAILS SHOULD DEPEND ON ABSTRACTIONS. DIP: The Dependency-Inversion Principle Layering An Inversion of Ownership Depend on Abstractions A Simple Example Finding the Underlying Abstraction The Furnace Example Dynamic v. Static Polymorphism Chapter 12 ISP: The Interface-Segregation Principle Interface Pollution Separate Clients Mean Separate Interfaces The Backwards Force Applied by Clients Upon Interfaces CLIENTS SHOULD NOT BE FORCED TO DEPEND ON METHODS THAT THEY DO NOT USE. ISP: The Interface-Segregation Principle Class Interfaces v. Object Interfaces Separation through Delegation Separation through Multiple Inheritance The ATM User Interface Example The Polyad v. the Monad 127 127 128 128 129 130 131 132 133 134 134 135 135 137 137 137 138 138 139 139 144 145 145 Section 3 The Payroll Case Study 147 Rudimentary Specification of the Payroll System Exercise Use Case 1: Add New Employee Use Case 2: Deleting an Employee Use Case 3: Post a Time Card Use Case 4: Posting a Sales Receipt Use Case"5: Posting a Union Service Charge Use Case 6: Changing Employee Details Use Case 7: Run the Payroll for Today Chapter 13 COMMAND and ACTIVE OBJECT Simple Commands Transactions Physical and Temporal Decoupling Temporal Decoupling UNDO 148 148 148 149 149 149 150 150 150 151 152 153 154 154 154

xvi Contents ACTIVE OBJECT Chapter 14 TEMPLATE METHOD & STRATEGY: Inheritance vs. Delegation TEMPLATE METHOD Pattern Abuse Bubble Sort STRATEGY Sorting Again Chapter 15 FACADE and MEDIATOR FACADE MEDIATOR Chapter 16 SINGLETON and MONOSTATE SINGLETON Benefits of the SINGLETON Costs of the SINGLETON SINGLETON in Action MONOSTATE Benefits of MONOSTATE Costs of MONOSTATE MONOSTATE in Action 155 159 159 161 162 164 165 168 170 172 172 173 173 174 176 176 177 178 179 179 179 180 182 182 182 187 187 Chapter 17 NULL OBJECT :S> 189 192 192 Chapter 18 The Payroll Case Study: Iteration One Begins Introduction Specification Analysis by Use Cases Adding Employees Deleting Employees Posting Time Cards Posting Sales Receipts Posting a Union Service Charge Changing Employee Details Payday Reflection: What Have We Learned? Finding the Underlying-Abstractions The Schedule Abstraction 193 193 193 194 195 196 196 197 197 198 199 201 201 201

Payment Methods Affiliations Chapter 19 The Payroll Case Study: Implementation Adding Employees The Payroll Database Using TEMPLATE METHOD to Add Employees Deleting Employees Global Variables Time Cards, Sales Receipts, and Service Charges Changing Employees Changing Classification What Was I Smoking? Paying Employees Do We Want Developers Making Business Decisions? Paying Salaried Employees Paying Hourly Employees Pay Periods: A Design Problem Main Program The Database Summary of Payroll Design History Resources 202 202 203 203 205 206 207 209 212 213 214 220 224 229 233 235 235 237 241 248 248 249 249 250 250 Section 4 Packaging the Payroll System 251 Chapter 20 Principles of Package Design Designing with Packages? Granularity: The Principles of Package Cohesion The Reuse-Release Equivalence Principle (REP) THE GRANULE OF REUSE IS THE GRANULE OF RELEASE. The Common-Reuse Principle (CRP) THE CLASSES IN A PACKAGE ARE REUSED TOGETHER. IF YOU REUSE ONE OF THE CLASSES IN A PACKAGE, YOU REUSE THEM ALL. The Common-Closure Principle (CCP) THE CLASSES IN A PACKAGE SHOULD BE CLOSED TOGETHER AGAINST THE SAME KINDS OF CHANGES. A CHANGE THAT AFFECTS A PACKAGE AFFECTS ALL THE CLASSES IN THAT PACKAGE AND NO OTHER PACKAGES. Summary of Package Cohesion Stability: The Principles of Package Coupling The Acyclic-Dependencies Principle (ADP) ALLOW NO CYCLES IN THE PACKAGE DEPENDENCY GRAPH. The Weekly Build Eliminating Dependency Cycles The Effect of a Cycle in the Package Dependency Graph 253 253 254 254 255 256 256 256 256 257 257 258

xviii Contents Breaking the Cycle The "Jitters" Top-Down Design The Stable-Dependencies Principle (SDP) DEPEND IN THE DIRECTION OF STABILITY. Stability Stability Metrics Not All Packages Should Be Stable Where Do We Put the High-level Design? The Stable-Abstractions Principle (SAP) A PACKAGE SHOULD BE AS ABSTRACT AS IT IS STABLE. Measuring Abstraction The Main Sequence Distance from the Main Sequence Chapter 21 FACTORY A Dependency Cycle Substitutable Factories Using Factories for Test Fixtures How Important Is It to Use Factories? Chapter 22 The Payroll Case Study (Part 2) Package Structure and Notation Applying the Common Closure Principle (CCP) Applying the Reuse-Release Equivalency Principle (REP) Coupling and Encapsulation Metrics Applying the Metrics to the Payroll Application Object Factories The Object Factory for Transactionlmplementation Initializing the Factories Rethinking the Cohesion Boundaries The Final Package Structure 259 259 260 261 261 262 263 264 264 265 265 266 268 269 271 272 273 274 274 274 275 276 277 278 279 281 282 285 286 286 287 287 290 290 Section 5 The Weather Station Case Study 291 Chapter 23 COMPOSITE Example: Composite Commands Multiplicity or Not Multiplicity Chapter 24 OBSERVER Backing into a Pattern The Digital Clock 293 294 295 297 297

xix 314 The Use of Diagrams in this Chapter 314 The OBSERVER Pattern 315 How OBSERVER Manages the Principles of OOD 316 316 Chapter 25 ABSTRACT SERVER, ADAPTER, and BRIDGE 317 ABSTRACT SERVER 318 Who Owns the Interface? 318 Adapter 319 The Class Form of ADAPTER 319 The Modem Problem, ADAPTERS and LSP 320 BRIDGE 322 324 325 Chapter 26 PROXY and STAIRWAY TO HEAVEN: Managing Third Party APIs 327 PROXY 327 Proxifying the Shopping Cart 332 Summary of PROXY 344 Dealing with Databases, Middleware, and Other Third Party Interfaces 345 STAIRWAY TO HEAVEN 347 Example of STAIRWAY TO HEAVEN 348 Other Patterns That Can Be Used with Databases 353 354 354 Chapter 27 Case Study: Weather Station 355 The Cloud Company 355 The WMS-LC Software 356 Language Selection 357 Nimbus-LC Software Design 357 24-Hour History and Persistence 368 Implementing the HiLo Algorithms 371 <=" 379 379 Nimbus-LC Requirements Overview 379 Usage Requirements 379 24-Hour History 379 User Setup 379 Administrative Requirements 380 Nimbus-LC Use'Cases 380 Actors 380 Use Cases 380 Measurement History 380 Setup 381 Administration 381 Nimbus-LC Release Plan 381 Introduction. 381 Release I 381

xx Contents Risks 382 Deliverable(s) 382 Release II 382 Use Cases Implemented 382 Risks 383 Deliverable(s) 383 Release III 383 Use Cases Implemented 383 Risks 383 Deliverable(s) 383 Section 6 The ETS Case Study 385 Chapter 28 VISITOR 387 The VISITOR Family of Design Patterns 388 VISITOR 388 VISITOR is Like a Matrix 391 ACYCLIC VISITOR 391 ACYCLIC VISITOR IS Like a Sparse Matrix 396 Using VISITOR in Report Generators 396 Other Uses of VISITOR 402 DECORATOR 403 Multiple Decorators 406 EXTENSION OBJECT 408 418 Reminder 418 418 Chapter 29 STATE 419 Overview of Finite State Automata 419 Implementation Techniques ' 421 Nested Switch/Case Statements 421 Interpreting Transition Tables 424 The STATE Pattern & 426 SMC The State-Machine Compiler 429 Where Should State Machines be Used? 432 High-Level Application Policies for GUIs 432 GUI Interaction Controllers 433 Distributed Processing 433 434 Listings 434 Turns t i 1 e. j ava Using Table Interpretation 434 Turnstile.java Generated by SMC, and Other Support Files 437 441 Chapter 30 The ETS Framework 443 Introduction 443 Project Overview " 443

xxi Early History 1993-1994 445 Framework? 445 Framework! 446 The 1994 Team 446 The Deadline 446 The Strategy 446 Results 447 Framework Design 448 The Common Requirements of the Scoring Applications 448 The Design of the Scoring Framework 450 A Case for TEMPLATE METHOD 453 Write a Loop Once 454 The Common Requirements of the Delivery Applications 456 The Design of the Delivery Framework 457 The Taskmaster Architecture 462 465 466 Appendix A UML Notation I: The CGI Example 467 Course Enrollment System: Problem Description 468 Actors 469 Use Cases 469 The Domain Model 472 The Architecture 476 Abstract Classes and Interfaces in Sequence Diagrams 485 Summary 486 487 Appendix B UML Notation II: The STATMUX 489 The Statistical Multiplexor Definition 489 The Software Environment 490 The Real-time Constraints 490 The Input Interrupt Service Routine 491 The Output Service Interrupt Routine 495 The Communications Protocol & 496 506 506 Appendix C A Satire of Two Companies 507 Rufus, Inc. Project Kickoff 507 Rupert Industries Project: -Alpha- 507 Appendix D The Source Code Is the Design 517 What Is Software Design? 517 Afterword 523 Index 525