Software Design Principles and Guidelines



Similar documents
Software Quality Factors OOA, OOD, and OOP Object-oriented techniques enhance key external and internal software quality factors, e.g., 1. External (v

Software Design Principles and Guidelines

Engineering Process Software Qualities Software Architectural Design

How To Develop Software

Functional Decomposition Top-Down Development

Software Engineering

Fourth generation techniques (4GT)

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Chapter 8 Approaches to System Development

Introduction to Embedded Systems. Software Update Problem

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

Software Paradigms (Lesson 1) Introduction & Procedural Programming Paradigm

Software Life Cycle Processes

Glossary of Object Oriented Terms

In the IEEE Standard Glossary of Software Engineering Terminology the Software Life Cycle is:

Aspect-Oriented Programming

JOURNAL OF OBJECT TECHNOLOGY

Managing a Fibre Channel Storage Area Network

Software Development Life Cycle (SDLC)

Introduction to Software Paradigms & Procedural Programming Paradigm

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Acknowledgement. Software Engineering. CS 3141: Team Software Project Introduction

Extend the value of your core business systems.

SEEM4570 System Design and Implementation Lecture 10 Software Development Process

Basic Trends of Modern Software Development

Introduction to Object-Oriented Programming

The Phases of an Object-Oriented Application

Software development life cycle. Software Engineering - II ITNP92 - Object Oriented Software Design. Requirements. Requirements. Dr Andrea Bracciali

Peter Mileff PhD SOFTWARE ENGINEERING. The Basics of Software Engineering. University of Miskolc Department of Information Technology

2. Analysis, Design and Implementation

An Introduction to Software Architecture

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Establishing Great Software Development Process(es) for Your Organization. By Dale Mayes

Chapter 11: Integrationand System Testing

SOFTWARE DESIGN TECHNIQUES. Nagalaxmi Telkar CSCI 5828 Presentation Slides

Data Abstraction and Hierarchy

Quotes from Object-Oriented Software Construction

Lecture 1: Introduction

SOFTWARE PROCESS MODELS

OO Design Quality Metrics

Patterns in Software Engineering

2. Analysis, Design and Implementation

Object Oriented Design

Patterns in. Lecture 2 GoF Design Patterns Creational. Sharif University of Technology. Department of Computer Engineering

Chap 1. Introduction to Software Architecture

Structure of Presentation. The Role of Programming in Informatics Curricula. Concepts of Informatics 2. Concepts of Informatics 1

Decomposition into Parts. Software Engineering, Lecture 4. Data and Function Cohesion. Allocation of Functions and Data. Component Interfaces

Managing Variability in Software Architectures 1 Felix Bachmann*

Module 2. Software Life Cycle Model. Version 2 CSE IIT, Kharagpur

Effective Java Programming. efficient software development

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities

A Case Study of the Systems Engineering Process in Healthcare Informatics Quality Improvement. Systems Engineering. Ali M. Hodroj

Levels of Software Testing. Functional Testing

COSC 3351 Software Design. Recap for the first quiz. Edgar Gabriel. Spring For the 1 st Quiz

Component Based Software Engineering: A Broad Based Model is Needed

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

Real Time Programming: Concepts

A Capability Maturity Model (CMM)

The Rules 1. One level of indentation per method 2. Don t use the ELSE keyword 3. Wrap all primitives and Strings

Requirements engineering

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Name of pattern types 1 Process control patterns 2 Logic architectural patterns 3 Organizational patterns 4 Analytic patterns 5 Design patterns 6

Applying 4+1 View Architecture with UML 2. White Paper

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Software maintenance. Software Maintenance. Fundamental problems. Maintenance activities. Lehman/Belady model of evolution. Topics

TRADITIONAL VS MODERN SOFTWARE ENGINEERING MODELS: A REVIEW

THE IMPACT OF INHERITANCE ON SECURITY IN OBJECT-ORIENTED DATABASE SYSTEMS

Software Engineering Introduction & Background. Complaints. General Problems. Department of Computer Science Kent State University

Reusable Knowledge-based Components for Building Software. Applications: A Knowledge Modelling Approach

And the Models Are System/Software Development Life Cycle. Why Life Cycle Approach for Software?


Course MS10975A Introduction to Programming. Length: 5 Days

Programming Languages

Test Driven Development of Embedded Systems Using Existing Software Test Infrastructure

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

Abstraction in Computer Science & Software Engineering: A Pedagogical Perspective

CSCI E 98: Managed Environments for the Execution of Programs

Life-Cycle Model. Software Life-Cycle Models. Software Development in Theory. Software Development in Practice

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Software Design Document (SDD) Template

SOFTWARE ENGINEERING INTERVIEW QUESTIONS

Java (12 Weeks) Introduction to Java Programming Language

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

SOFTWARE ENGINEERING IT 0301 Semester V B.Nithya,G.Lakshmi Priya Asst Professor SRM University, Kattankulathur

CS Standards Crosswalk: CSTA K-12 Computer Science Standards and Oracle Java Programming (2014)

Umbrella: A New Component-Based Software Development Model

Karunya University Dept. of Information Technology

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

Fundamentals of Java Programming

CS 451 Software Engineering Winter 2009

Introduction and Overview

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

1 Organization of Operating Systems

Java Application Developer Certificate Program Competencies

F-16 Modular Mission Computer Application Software

Layered Approach to Development of OO War Game Models Using DEVS Framework

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

Transcription:

Design Principles and Guidelines Overview CS 342: Object-Oriented Software Development Lab Software Design Principles and Guidelines David L. Levine Christopher D. Gill Department of Computer Science Washington University, St. Louis levine,cdgill@cs.wustl.edu http://classes.cec.wustl.edu/çcs342/ Design Principles Important design concepts Useful design principles Evaluation criteria Development Methodologies Traditional approaches Extreme programming Design Guidelines Motivation Common Design Mistakes Design Rules Copyright c1997-2000 Dept. of Computer Science, Washington University 1 Motivation: Goals of the Design Phase Decompose System into Modules i.e., identify the software architecture Modules are abstractions that should: be independent, have well-specified interfaces, and have high cohesion and low coupling. Determine Relations Between Modules Identify module dependencies Determine the form of intermodule communication, e.g., global variables parameterized function calls shared memory RPC or message passing Motivation: Goals of the Design Phase (cont d) Specify Module Interfaces Interfaces should be well-defined facilitate independent module testing improve group communication Describe Module Functionality Informally e.g., comments or documentation Formally e.g., via module interface specification languages Copyright c1997-2000 Dept. of Computer Science, Washington University 2 Copyright c1997-2000 Dept. of Computer Science, Washington University 3

Primary Design Phases Key Design Concepts and Principles Preliminary Design External design describes the real-world model Architectural design decomposes the requirement specification into software subsystems Detailed Design Formally specify each subsystem Further decomposed subsystems, if necessary Note: in design phases the orientation moves from customer to developer from what to how Important design concepts and design principles include: Decomposition Abstraction Subset Identification Information Hiding Virtual Machine Structuring Modularity Separating Policy and Mechanism Hierarchy Main purpose of these concepts and principles is to manage software system complexity and improve software quality factors. Copyright c1997-2000 Dept. of Computer Science, Washington University 4 Copyright c1997-2000 Dept. of Computer Science, Washington University 5 Decomposition Decomposition (cont d) Decomposition is a concept common to all life-cycle and design techniques. Basic concept is very simple: 1. Select a piece of the problem (initially, the whole problem) 2. Determine its components using the mechanism of choice, e.g., functional vs data structured vs object-oriented 3. Show how the components interact 4. Repeat steps 1 through 3 until some termination criteria is met (e.g., customer is satisfied, run out of money, etc.;-)) Some guiding decomposition principles Because design decisions transcend execution time, modules might not correspond to execution steps... Decompose so as to limit the effect of any one design decision on the rest of the system Remember, anything that permeates the system will be expensive to change Modules should be specified by all information needed to use the module and nothing more Copyright c1997-2000 Dept. of Computer Science, Washington University 6 Copyright c1997-2000 Dept. of Computer Science, Washington University 7

Abstraction Abstraction (cont d) Abstraction provides a way to manage complexity by emphasizing essential characteristics and suppressing implementation details. Allows postponement of certain design decisions that occur at various levels of analysis, e.g., Representational/Algorithmic considerations Architectural/Structural considerations External/Functional considerations Three basic abstraction mechanisms Procedural abstraction e.g., closed subroutines Data abstraction e.g., ADTs Control abstraction iterators, loops, multitasking, etc. Copyright c1997-2000 Dept. of Computer Science, Washington University 8 Copyright c1997-2000 Dept. of Computer Science, Washington University 9 Information Hiding Information Hiding (cont d) Motivation: details of design decisions that are subject to change should be hidden behind abstract interfaces, i.e., modules. Information hiding is one means to enhance abstraction. Modules should communicate only through well-defined interfaces. Each module is specified by as little information as possible. If internal details change, client modules should be minimally affected (may require recompilation and relinking, however...) Information to be hidden includes: Data representations i.e., using abstract data types Algorithms e.g., sorting or searching techniques Input and Output Formats Machine dependencies, e.g., byte-ordering, character codes Policy/mechanism distinctions i.e., when vs how e.g., OS scheduling, garbage collection, process migration Lower-level module interfaces e.g., Ordering of low-level operations, i.e., process sequence Copyright c1997-2000 Dept. of Computer Science, Washington University 10 Copyright c1997-2000 Dept. of Computer Science, Washington University 11

Modularity Modularity (cont d) A Modular System is a system structured into highly independent abstractions called modules. Modularity is important for both design and implementation phases. Module prescriptions: Modules should possess well-specified abstract interfaces. Modules should have high cohesion and low coupling. Modularity facilitates certain software quality factors, e.g.: Extensibility - well-defined, abstract interfaces Reusability - low-coupling, high-cohesion Compatibility - design bridging interfaces Portability - hide machine dependencies Modularity is an important characteristic of good designs because it: allows for separation of concerns enables developers to reduce overall system complexity via decentralized software architectures enhances scalability by supporting independent and concurrent development by multiple personnel Copyright c1997-2000 Dept. of Computer Science, Washington University 12 Copyright c1997-2000 Dept. of Computer Science, Washington University 13 Modularity (cont d) Modularity (cont d) A module is A software entity encapsulating the representation of an abstraction, e.g., anadt A vehicle for hiding at least one design decision A work assignment for a programmer or group of programmers a unit of code that has one or more names has identifiable boundaries can be (re-)used by other modules encapsulates data hides unnecessary details can be separately compiled (if supported) A module is not necessarily a subroutine or arbitrary pieces of code... All ADTs are modules Note all modules are ADTs, however. e.g., groups of functionally related procedures (such as sorting) can form a module, but not be an ADT. Copyright c1997-2000 Dept. of Computer Science, Washington University 14 Copyright c1997-2000 Dept. of Computer Science, Washington University 15

Modularity (cont d) A module interface consists of several sections: Imports Services requested from other modules Exports Services provided to other modules Access Control not all clients are equal! (e.g., C++ s distinction between protected/private/public) Heuristics for determining interface specification define one specification that allows multiple implementations anticipate change e.g., use structures and classes for parameters Modularity Dimensions Modularity has several dimensions and encompasses specification, design, and implementation levels: Criteria for evaluating design methods with respect to modularity Modular Decomposability Modular Composability Modular Understandability Modular Continuity Modular Protection Principles for ensuring modular designs: Language Support for Modular Units Few Interfaces Small Interfaces (Weak Coupling) Explicit Interfaces Information Hiding Copyright c1997-2000 Dept. of Computer Science, Washington University 16 Copyright c1997-2000 Dept. of Computer Science, Washington University 17 Criteria for Evaluating Modular Designs Modular Decomposability Does the method aid decomposing a new problem into several separate subproblems? (e.g., top-down functional design) Modular Composability Does the method aid constructing new systems from existing software components? (e.g., bottom-up design) Modular Understandability Are modules separately understandable by a human reader, e.g., how tightly coupled are they? Criteria for Evaluating Modular Designs (cont d) Modular Continuity Do small changes to the specification affect a localized and limited number of modules? Modular Protection Are the effects of run-time abnormalities confined to a small number of related modules? Copyright c1997-2000 Dept. of Computer Science, Washington University 18 Copyright c1997-2000 Dept. of Computer Science, Washington University 19

Principles for Ensuring Modular Designs Principles for Ensuring Modular Designs (cont d) Language Support for Modular Units Modules must correspond to syntactic units in the language used. Few Interfaces Every module should communicate with as few others as possible. Small Interfaces (Weak Coupling) If any two modules communicate at all, they should exchange as little information as possible. Explicit Interfaces Whenever two modules A and B communicate, this must be obvious from the text of A or B or both. Information Hiding All information about a module should be private to the module unless it is specifically declared public. Copyright c1997-2000 Dept. of Computer Science, Washington University 20 Copyright c1997-2000 Dept. of Computer Science, Washington University 21 The Open/Closed Principle The Open/Closed Principle (cont d) A satisfactory module decomposition technique should yield modules that are both open and closed: Open Module: is one still available for extension. This is necessary because the requirements and specifications are rarely completely understood from the system s inception. Closed Module: is available for use use by other modules, usually given a well-defined, stable description and packaged in a library. This is necessary because otherwise code sharing becomes unmanageable because reopening a module may trigger changes in many clients. Traditional design techniques and programming languages do not offer an elegant solution to the problem of producing modules that are both open and closed. Object-oriented methods utilize inheritance and dynamic binding to solve this problem. Copyright c1997-2000 Dept. of Computer Science, Washington University 22 Copyright c1997-2000 Dept. of Computer Science, Washington University 23

Case Study: Arithmetic Expression Evaluation Initial specification: write a four-function calculator utility that evaluates arithmetic expressions of the form: (10 + 20) * 30.0 / 49-37 Typical solution in Ada, Pascal, or C makes use of enumerated types and a case or switch statement, e.g., enum op_type { ADD, SUB, MUL, DIV }; //... void apply (op_type op_code, double v1, double v2) { switch (op_code) { case ADD: //... case SUB: //... case MUL: //... case DIV: //... } } Copyright c1997-2000 Dept. of Computer Science, Washington University 24 Case Study: Arithmetic Expression Evaluation (cont d) However, problems arise when the calculator s functionality is enhanced by adding new operations, e.g., extending it to handle complete C or C++ expression syntax. Programs that utilize case analysis and enumerated types are often difficult to update, enhance, and maintain. OOD/OOP provide a more flexible and extensible solution using inheritance and dynamic binding. Copyright c1997-2000 Dept. of Computer Science, Washington University 25 Virtual Machine Structuring A virtual machine architecture is used to decompose system into smaller, more manageable units. A virtual machine provides an extended software instruction set Extensions provide additional data types and associated software instructions Modeled after hardware instruction set primitives that work on a limited set of data types Virtual Machine Structuring (cont d) A virtual machine component provides a set of operations that are useful in developing a family of similar systems Reusability is limited if virtual machine operations merely correspond to steps in processing from input to output, i.e., use the shopping list approach. It is difficult to obtain good performance at level N, if levels below N are not implemented efficiently. Virtual machines allow incremental extensions But beware of overly narrow interfaces in lower layer virtual machines... Copyright c1997-2000 Dept. of Computer Science, Washington University 26 Copyright c1997-2000 Dept. of Computer Science, Washington University 27

Virtual Machine Structuring (cont d) Good examples of virtual machine concept: Computer Architectures e.g., compiler! assembler! obj code! microcode! gates, transistors, signals, etc. Communication protocol stacks, e.g., ISO, TCP/IP Operating systems, e.g., Mach, BSD UNIX, e.g., HARDWARE MACHINE instruction set restartable instructions interrupts/traps interrupt/trap handlers blocking interrupts interrupt stack SOFTWARE VIRTUAL MACHINE set of system calls restartable system calls signals signal handlers masking signals signal stack Hierarchy Motivation: reduces module interactions by restricting the topology of relationships A relation defines a hierarchy if it partitions units into levels (note connection to virtual machines) Level 0 is the set of all units that use no other units Level i is the set of all units that use at least one unit at level é i and no unit at level ç i. Hierarchical structure forms basis of design Facilitates independent development Isolates ramifications of change Allows rapid prototyping Copyright c1997-2000 Dept. of Computer Science, Washington University 28 Copyright c1997-2000 Dept. of Computer Science, Washington University 29 Hierarchy (cont d) The Uses Relation Relations that define hierarchies: Uses Is-Composed-Of Is-A Has-A The first two are general to all design methods, the latter two are more particular to object-oriented design and programming. X Uses Y if the correct functioning of X depends on the availability of a correct implementation of Y Note, uses is not necessarily the same as invokes: Some invocations are not uses e.g., error logging Some uses don t involve invocations e.g., message passing, interrupts, shared memory access A uses relation does not necessarily yield a hierarchy (avoid cycles...) Copyright c1997-2000 Dept. of Computer Science, Washington University 30 Copyright c1997-2000 Dept. of Computer Science, Washington University 31

The Uses Relation (cont d) Allow X to use Y when: X is simpler because it uses Y e.g., Standard C library routines Y is not substantially more complex because it is not allowed to use X i.e., hierarchies should be semantically meaningful there is a useful subset containing Y and not X i.e., allows sharing and reuse of Y there is no conceivably useful subset containing X but not Y i.e., Y is necessary for X to function correctly. The Uses Relation, (cont d) How should recursion be handled? Group X and Y as a single entity in the uses relation. A hierarchy in the uses relation is essential for designing non-trivial reusable software systems. Note that certain software systems require some form of controlled violation of a uses hierarchy e.g., asynchronous communication protocols, call-back schemes, signal handling, etc. Upcalls are one way to control these non-hierarchical dependencies Rule of thumb : Start with an invocation hierarchy and eliminate those invocations ( calls ) that are not uses relationships. Copyright c1997-2000 Dept. of Computer Science, Washington University 32 Copyright c1997-2000 Dept. of Computer Science, Washington University 33 The Is-Composed-Of Relation The is-composed-of relationship shows how the system is broken down in components. X is-composed-of fx i g if X is a group of units x i that share some common purpose The system structure graph description can be specified by the iscomposed-of relation such that: non-terminals are virtual code terminals are the only units represented by actual (concrete) code The Is-Composed-Of Relation, (cont d) Many programming languages support the is-composed-of relation via some higher-level module or record structuring technique. Note: the following are not equivalent: 1. level (virtual machine) 2. module (an entity that hides a secret) 3. a subprogram (a code unit) Modules and levels need not be identical, as a module may have several components on several levels of a uses hierarchy. Copyright c1997-2000 Dept. of Computer Science, Washington University 34 Copyright c1997-2000 Dept. of Computer Science, Washington University 35

The Is-A and Has-A Relations Separate Policy and Mechanism These two relationships are associated with object-oriented design and programming languages that possess inheritance and classes. Is-A or Descendant relationship class X possesses Is-A relationship with class Y if instances of class X are specialization of class Y. e.g., a square is a specialization of a rectangle, which is a specialization of a shape... Has-A or Containment relationship class X possesses a Has-B relationship with class Y if instances of class X contain one or more instance(s) of class Y. e.g., a car has an engine and four tires... Very important design principle, used to separate concerns at both the design and implementation phases. Multiple policies can be implemented by shared mechanisms. e.g., OS scheduling and virtual memory paging Same policy can be implemented by multiple mechanisms. e.g., FIFO containment can be implemented using a stack based on an array, or a linked list, or... e.g., reliable, non-duplicated, bytestream service can be provided by multiple communication protocols. Copyright c1997-2000 Dept. of Computer Science, Washington University 36 Copyright c1997-2000 Dept. of Computer Science, Washington University 37 Program Families and Subsets Program Families and Subsets (cont d) Program families are a collection of related modules or subsystems that form a framework e.g., BSD UNIX network protocol subsystem. Note,a framework is a set of abstract and concrete classes. Program families are natural way to detect and implement subsets. Reasons for providing subsets include cost, time, personnel resources, etc. Identifying subsets: Analyze requirements to identify minimally useful subsets. Also identify minimal increments to subsets. Advantages of subsetting: Facilitates software system extension and contraction Promotes reusability Anticipates potential changes Note: it is most important to design for flexibility, not necessarily for generality... Copyright c1997-2000 Dept. of Computer Science, Washington University 38 Copyright c1997-2000 Dept. of Computer Science, Washington University 39

Program Families and Subsets (cont d) Families provide integrated support for different services for different markets, e.g., different alphabets, different vertical applications, different I/O formats different hardware or software platforms e.g., compilers or OSs different resource trade-offs e.g., speed vs space different internal resources e.g., shared data structures and library routines different external events e.g., UNIX I/O device interface backward compatibility e.g., sometimes it is important to retain bugs! A General Design Process Given a specification, design involves an iterative decision making process with the following general steps: List the difficult decisions and decisions likely to change Design a module specification to hide each such decision Make decisions that apply to whole program family first Modularize most likely changes first Then modularize remaining difficult decisions and decisions likely to change Design the uses hierarchy as you do this (include reuse decisions) Copyright c1997-2000 Dept. of Computer Science, Washington University 40 Copyright c1997-2000 Dept. of Computer Science, Washington University 41 A General Design Process (cont d) General steps (cont d) Treat each higher-level module as a specification and apply above process to each Continue refining until all design decisions are: hidden in a module contain easily comprehensible components provide individual, independent, low-level implementation assignments Traditional Development Methodologies Waterfall Model Specify, analyze, implement, test (in sequence) Assumes that requirements can be specified up front Spiral Model Supports iterative development Attempts to assess risks of changes Rapid Application Development Build a prototype Ship it :-) Copyright c1997-2000 Dept. of Computer Science, Washington University 42 Copyright c1997-2000 Dept. of Computer Science, Washington University 43

extreme Programming Stresses customer satisfaction, and therefore, involvement Provide what the customer wants, as quickly as possible Provide only what the customer wants Encourages changes in requirements Relies on testing XP Practices Planning, designing, coding, testing User Story Requirements System Prototype Technology Spike Time extreme Programming: Planning Planning Game Risk Estimates Change in Requirements, Risk, or Developement Environment Commitment Schedule based on http://www.extremeprogramming.org/rules/planninggame.html Iteration Start with user stories Written by customers, to specify system requirements Minimal detail, typically just a few sentences on a card Expected development time: 1 to 3 weeks each, roughly Planning game creates commitment schedule for entire project Each iteration should take 2-3 weeks Copyright c1997-2000 Dept. of Computer Science, Washington University 44 Copyright c1997-2000 Dept. of Computer Science, Washington University 45 extreme Programming: Designing Defer design decisions as long as possible Advantages: Simplifies current task (just build what is needed) You don t need to maintain what you haven t built Time is on your side: you re likely to learn something useful by the time you need to decide Tomorrow may never come: if a feature isn t needed now, it might never be needed Disadvantages: Future design decisions may require rework of existing implementation Ramp-up time will probably be longer later Therefore, always try to keep designs as simple as possible extreme Programming: Coding Pair programming Always code with a partner Always test as you code Pair programming pays off by supporting good implementation, reducing mistakes, and exposing more than one programmer to the design/implementation If any deficiencies in existing implementation are noticed, either fix them or note that they need to be fixed. Copyright c1997-2000 Dept. of Computer Science, Washington University 46 Copyright c1997-2000 Dept. of Computer Science, Washington University 47

extreme Programming: Testing Unit tests are written before code. Code must pass both its unit test and all regression tests before committing. In effect, the test suite defines the system requirements. Significant difference from other development approaches. If a bug is found, a test for it must be added. If a feature isn t tested, it can be removed. extreme Programming: Information Sources Kent Beck, Extreme Programming Explained: Addison-Wesley, ISBN 0201616416, 1999. Embrace Change, Kent Beck, Extreme Programming, C++ Report 11:5, May 1999, pp. 26 29+. John Vlissides, XP, interview with Kent Beck in the Pattern Hatching Column, C++ Report 11:6, June 1999, pp. 44-52+. Kent Beck, Embracing Change with Extreme Programming, IEEE Computer 32:10, October 1999, pp. 70-77. http://www.extremeprogramming.org/ http://www.xprogramming.com/ http://c2.com/cgi/wiki?extremeprogrammingroadmap Copyright c1997-2000 Dept. of Computer Science, Washington University 48 Copyright c1997-2000 Dept. of Computer Science, Washington University 49 Design Guidelines: Motivation Design is the process of organizing structured solutions to tasks from a problem domain. This process is carried out in many disciplines, in many ways. There are many similarities and commonalities among design processes. There are also many common design mistakes... The following pages provide a number of design rules. Remember, these rules are simply suggestions on how to better organize your design process, not a recipe for success! Common Design Mistakes Depth-first design only partially satisfy the requirements experience is best cure for this problem... Directly refining requirements specification leads to overly constrained, inefficient designs Failure to consider potential changes always design for extension and contraction Making the design too detailed this overconstrains the implementation Copyright c1997-2000 Dept. of Computer Science, Washington University 50 Copyright c1997-2000 Dept. of Computer Science, Washington University 51

Common Design Mistakes (cont d) Ambiguously stated design misinterpreted at implementation Undocumented design decisions designers become essential to implementation Inconsistent design results in a non-integratable system, because separately developed modules don t fit together. Rules of Design Make sure that the problem is well-defined All design criteria, requirements, and constraints, should be enumerated before a design is started. This may require a spiral model approach. What comes before how i.e., define the service to be performed at every level of abstraction before deciding which structures should be used to realize the services. Separate orthogonal concerns Do not connect what is independent. Important at many levels and phases... Copyright c1997-2000 Dept. of Computer Science, Washington University 52 Copyright c1997-2000 Dept. of Computer Science, Washington University 53 Rules of Design (cont d) Design external functionality before internal functionality. First consider the solution as a black-box and decide how it should interact with its environment. Then decide how the black-box can be internally organized. Likely it consists of smaller black-boxes that can be refined in a similar fashion. Keep it simple. Fancy designs are buggier than simple ones; they are harder to implement, harder to verify, and often less efficient. Problems that appear complex are often just simple problems huddled together. Our job as designers is to identify the simpler problems, separate them, and then solve them individually. Rules of Design (cont d) Work at multiple levels of abstraction Good designers must be able to move between various levels of abstraction quickly and easily. Design for extensibility A good design is open-ended, i.e., easily extendible. A good design solves a class of problems rather than a single instance. Do not introduce what is immaterial. Do not restrict what is irrelevant. Use rapid prototyping when applicable Before implementing a design, build a high-level prototype and verify that the design criteria are met. Copyright c1997-2000 Dept. of Computer Science, Washington University 54 Copyright c1997-2000 Dept. of Computer Science, Washington University 55

Rules of Design (cont d) Details should depend upon abstractions Abstractions should not depend upon details Principle of Dependency Inversion The granule of reuse is the same as the granule of release Only components that are released through a tracking system can be effectively reused Classes within a released component should share common closure That is, if one needs to be changed, they all are likely to need to be changed i.e., what affects one, affects all Rules of Design (cont d) Classes within a released component should be reused together That is, it is impossible to separate the components from each other in order to reuse less than the total The dependency structure for released components must be a DAG There can be no cycles Dependencies between released components must run in the direction of stability The dependee must be more stable than the depender The more stable a released component is, the more it must consist of abstract classes A completely stable component should consist of nothing but abstract classes Copyright c1997-2000 Dept. of Computer Science, Washington University 56 Copyright c1997-2000 Dept. of Computer Science, Washington University 57 Rules of Design (cont d) Rules of Design (cont d) Where possible, use proven patterns to solve design problems When crossing between two different paradigms, build an interface layer that separates the two Don t pollute one side with the paradigm of the other Software entities (classes, modules, etc) should be open for extension, but closed for modification The Open/Closed principle Bertrand Meyer Derived classes must usable through the base class interface without the need for the user to know the difference The Liskov Substitution Principle Copyright c1997-2000 Dept. of Computer Science, Washington University 58 Copyright c1997-2000 Dept. of Computer Science, Washington University 59

Rules of Design (cont d) Make it work correctly, then make it work fast Implement the design, measure its performance, and if necessary, optimize it. Maintain consistency between representations e.g., check that the final optimized implementation is equivalent to the high-level design that was verified. Also important for documentation... Don t skip the preceding rules! Clearly, this is the most frequently violated rule!!! ;-) Copyright c1997-2000 Dept. of Computer Science, Washington University 60