Principles of High-Level Design

Slides:



Advertisements
Similar presentations
Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Advertisements

•7/12 /07 F-1 © 2010 T. Horton CS 4240 Principles of SW Design Packages in Java and UML.
Object-Oriented Software Development CS 3331 Fall 2009.
Chapter 2 – Software Processes
Stability and Volatility is Software Design H. Rahnama Tutorial in software engineering.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Software Issues Derived from Dr. Fawcett’s Slides Phil Pratt-Szeliga Fall 2009.
Package design and the Iterative process model. What is a package? Classes are not sufficient to group code –Some classes collaborate, implying dependencies.
Logical Architecture and UML Package Diagrams
TEST-1 7. Object-Oriented Design Principles. TEST-2 The Pillars of the Paradigm Abstraction Encapsulation Hierarchy –Association, Aggregation –Inheritance.
Chapter 13 Starting Design: Logical Architecture and UML Package Diagrams.
1 OO Design Principles Project Group eXtreme Programming Md. Abul Bashar 07/09/2004.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
S/W Project Management Software Process Models. Objectives To understand  Software process and process models, including the main characteristics of.
Alexander Serebrenik, Serguei Roubtsov, and Mark van den Brand D n -based Design Quality Comparison of Industrial Java Applications.
CSE 303 – Software Design and Architecture
1 OO Design Novosoft, 2001 by V. Mukhortov. 2 OO Design Goals  Flexibility Changes must be localized  Maintainability Modules requiring changes can.
CS 360 Lecture 3.  The software process is a structured set of activities required to develop a software system.  Fundamental Assumption:  Good software.
Ch:10 Component Level Design Unit 4. What is Component? A component is a modular building block for computer software Because components reside within.
Requirements To Design--Iteratively Chapter 12 Applying UML and Patterns Craig Larman.
Advanced Principles II Principles of Object-Oriented Component Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this.
CSSE 374: More GRASP’ing for Object Responsibilities
Cohesion and Coupling CS 4311
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
4/1/05F-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Packages and Components in Java and UML.
1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles.
Basic Concepts of Component- Based Software Development (CBSD) Model-Based Programming and Verification.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Chapter 2 – Software Processes Lecture 1 Chapter 2 Software Processes1.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
CSE 303 – Software Design and Architecture
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Key Principles of Software Architecture and Design (II) adapted from Dave Penny’s.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
1 Good Object-Oriented Design Radu Marinescu Lecture 3 Principles of Object-Oriented Design Part II 19 th November 2002.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Principles of Package Design COMPOSE AT A HIGHER LEVEL OF ABSTRACTION.
1 Advanced Object- oriented Design – Principles CS320 Fall 2005.
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
1 Advanced Object-oriented Design – Principles and Patterns OO Design Principles.
by C.A. Conley and L. Sproull
CompSci 280 S Introduction to Software Development
Abstract Factory Pattern
Metrics of Software Quality
Chapter 12 Object Oriented Design Principles
N-Tier Architecture.
Coupling and Cohesion 1.
Chapter 12 Object Oriented Design Principles
Unfunded Liabilities: How Poor Package Design Drives Technical Debt and What You Can Do About It Allen C Smith, CLA Senior Systems Engineer, ATE.
Abstract Factory Pattern
Principles of Package Architecture
Software Design Designing the overall structure (architecture) of a software system Designing small pieces of computation Designing non-automated processes.
Object-Oriented Design
Starting Design: Logical Architecture and UML Package Diagrams
Software Design Lecture : 9.
CSE 303 Concepts and Tools for Software Development
An Introduction to Software Architecture
UNIT 5 EMBEDDED SYSTEM DEVELOPMENT
UNIT 5 EMBEDDED SYSTEM DEVELOPMENT
Principles of Object-Oriented Design
Better Architecture Management Made Easy
Principles of Object-Oriented Design Part II
Principles of Object-Oriented Design
Logical Architecture & UML Package Diagrams
Chapter 10 – Component-Level Design
Presentation transcript:

Principles of High-Level Design Lecture 5

High-Level Design Dealing with large-scale systems > 50 KLOC team of developers, rather than an individual Classes are a valuable but not sufficient mechanism too fine-grained for organizing a large scale design need mechanism that impose a higher level of order clusters (Meyer); class-category (Booch); subject-areas (Coad) Packages a logical grouping of declarations that can be imported in other programs (in Java and Ada) containers for a group of classes (UML) reason at a higher-level of abstraction Lecture 5

Issues of High-Level Design Goal partition the classes in an application according to some criteria and then allocate those partitions to packages Issues What are the best partitioning criteria? What principles govern the design of packages? creation and dependencies between packages Design packages first? Or classes first? i.e. top-down vs. bottom-up approach Approach Define principles that govern package design the creation and interrelationship and use of packages Lecture 5

Principles of OO High-Level Design Cohesion Principles Reuse/Release Equivalency Principle (REP) Common Reuse Principle (CRP) Common Closure Principle (CCP) Coupling Principles Acyclic Dependencies Principle (ADP) Stable Dependencies Principle (SDP) Stable Abstractions Principle (SAP) Lecture 5

What is really Reusability ? Does copy-paste mean reusability? Disadvantage: You own that copy! you must change it, fix bugs. eventually the code diverges Maintenance is a nightmare Martin’s Definition: I reuse code if, and only if, I never need to look at the source-code treat reused code like a product  don’t have to maintain it Clients (re-users) may decide on an appropriate time to use a newer version of a component release Lecture 5

Reuse/Release Equivalency Principle (REP) The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused. R. Martin, 1996 What means this ? A reusable software element cannot really be reused in practice unless it is managed by a release system of some kind e.g. release numbers or names There is no such thing as ”reusable class” without guarantees of notification, safety and support must integrate the entire module (can’t reuse less) Either all the classes in a package are reusable or none of it is! R. Martin, 1996 Lecture 5

The Common Reuse Principle All classes in a package [library] should be reused together. If you reuse one of the classes in the package, you reuse them all. R. Martin, Granularity 1996 Packages of reusable components should be grouped by expected usage, not by… … common functionality, nor … another arbitrary categorization. Classes are usually reused in groups based on collaborations between library classes e.g. containers and iterators When I depend on a package, I like to depend on every class in that package! Lecture 5

Common Closure Principle (CCP) The classes in a package should be closed against the same kinds of changes. A change that affects a package affects all the classes in that package R. Martin, 1996 What means this ? Classes that change together belong together Goal: limit the dispersion of changes among released packages changes must affect the smallest number of released packages relation with OCP Classes within a package must be cohesive Given a particular kind of change, either all classes or no class in a component needs to be modified Lecture 5

Reuse vs. Maintenance REP and CRP makes life easier for reuser packages very small CCP makes life easier for maintainer large packages Packages are not fixed in stone early lifetime dominated by CCP later you want to reuse: focus on REP CRP Lecture 5

Morning-After Syndrome You go home and discover the next morning that your stuff is not working anymore… WHY? Some worked later than you ;-) Morning-After syndrome Many developers modify the same source files Unable to build a stable version of the system Everyone tries to adapt to the changes that other made Two solutions Weekly Build Eliminating Dependency Cycles Lecture 5

Everyone ignores the other for 4 days out of 5 The Weekly Build Everyone ignores the other for 4 days out of 5 Works on private copies of the code Friday the whole system is integrated Less feasible as program grows Build flows over in Saturday …May be it should start already on Thursday Creeps toward the middle of the week Biweekly build…still not scalable Lecture 5

Eliminating Dependency Cycles Partition work in reusable packages (i.e. units of work) When a package is working it is release for the others “Users” get notified They can decide if they want to integrate or not They choose the integration moment None of the teams is at the mercy of others One Precondition: there can be no cycles in the package structure! Lecture 5

Acyclic Graph of Dependencies Directed Graph Arrows indicate who depends on whom When MyDialogs changes only a few other packages are affected When MyDialogs is tested, it depends only on Windows Release of the whole system bottom-up Lecture 5

Cyclic Dependencies Lecture 5

Acyclic Dependencies Principles (ADP) The dependency structure for released component must be a Directed Acyclic Graph (DAG) There can be no cycles. R. Martin, 1996 Lecture 5

Breaking the Cycles Lecture 5

“Copy” Program Revisited class Reader { public: virtual int read()=0; }; class Writer { virtual void write(int)=0; void Copy(Reader& r, Writer& w){ int c; while((c = r.read()) != EOF) w.write(c); } Copy Reader Writer Disk Writer Keyboard Reader Printer Writer Why are these dependencies good? (better than earlier) Lecture 5

Good Dependencies Targets of unavoidable dependencies are non-volatile unlikely to change e.g. Reader and Writer classes have a low volatility  the Copy class is “immune” to changes A “Good Dependency” is a dependency upon something with low volatility. Lecture 5

Volatility and Stability Volatility Factors hard-coding of improper information e.g. print version number market pressure whims of customers Volatility is difficult to understand and predict Stability defined as “not easily moved” a measure of the difficulty in changing a module not a measure of the likelihood of a change modules that are stable are going to be less volatile e.g. Reader and Writer classes are stable Stability = Responsibility + Independence Lecture 5

Stability Metrics Afferent Coupling (Ca) Efferent Coupling (Ce) number of classes outside this package that depend upon the measured package "how responsible am I?" (FAN-IN) Efferent Coupling (Ce) number of classes outside this package that classes within the measured package depend on "how dependent am I ?" (FAN-OUT) Instability Factor (I) I  [0, 1] 0 = totally stable; 1 = totally unstable Lecture 5

Computing Stability Metrics Ca = 4 Ce = 3 I = 3 / 6 Lecture 5

Stable Dependencies Principle (SDP) The dependencies between components in a design should be in the direction of stability. A component should only depend upon components that are more stable than it is. R. Martin, 1996 Depend only upon components whose I metric is lower than yours R. Martin, 1996 SDP Violation Lecture 5

Where to Put High-Level Design? High-level architecture and design decisions don't change often shouldn't be volatile  place them in stable packages design becomes hard to change  inflexible design How can a totally stable package (I = 0) be flexible enough to withstand change? improve it without modifying it... Answer: The Open-Closed Principle classes that can be extended without modifying them  Abstract Classes Lecture 5

Stable Abstractions Principle (SAP) The abstraction of a package should be proportional to its stability! Packages that are maximally stable should be maximally abstract. Instable packages should be concrete. R. Martin, 1996 Ideal Architecture Instable (changeable) packages on the top must be concrete Stable (hard to change) package on the bottom hard to change, but easy to extend highly abstract (easily extended) Interfaces have more intrinsic stability than executable code SAP is a restatement of DIP Lecture 5

Measuring Abstraction Abstraction of a Package A  [0, 1] 0 = no abstract classes 1 = all classes abstract Metric A is imperfect, but usable hybrid classes are also counted as abstract including pure virtual functions Alternative find a metric based on the ratio of virtual functions Lecture 5

Instability (I) should increase as abstraction (A) decreases. The Main Sequence Instability (I) should increase as abstraction (A) decreases. R. Martin, 2000 Lecture 5

Main Sequence (contd.) Zone of Pain Zone of Uselessness Main Sequence highly stable and concrete  rigid famous examples: database-schemas (volatile and highly depended-upon) concrete utility libraries (instable but non-volatile) Zone of Uselessness instable and abstract  useless no one depends on those classes Main Sequence maximizes the distance between the zones we want to avoid depicts the balance between abstractness and stability. Lecture 5

Measurement of OO Architectures Distance Normalized Distance ranges from [0, ~0.707] ranges from [0, 1] 0 = package on the main sequence 1 = package far away from main seq. Lecture 5