1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles.

Slides:



Advertisements
Similar presentations
•7/12 /07 F-1 © 2010 T. Horton CS 4240 Principles of SW Design Packages in Java and UML.
Advertisements

Stability and Volatility is Software Design H. Rahnama Tutorial in software engineering.
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
Software Requirements Engineering
SOLID Object Oriented Design Craig Berntson
1 Software Maintenance and Evolution CSSE 575: Session 6, Part 1 The “SEAM” Model Steve Chenoweth Office Phone: (812) Cell: (937)
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
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.
Package design and the Iterative process model. What is a package? Classes are not sufficient to group code –Some classes collaborate, implying dependencies.
Systems Design. Analysis involves understanding and documenting user requirements in a clear and unambiguous way. It focuses on the business side and.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
TEST-1 7. Object-Oriented Design Principles. TEST-2 The Pillars of the Paradigm Abstraction Encapsulation Hierarchy –Association, Aggregation –Inheritance.
Pedro Mejia Alvarez CINVESTAV-PN
1 OO Design Principles Project Group eXtreme Programming Md. Abul Bashar 07/09/2004.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
Design Patterns.
CLASS DESIGN PRINCIPLES Lecture 2. The quality of the architecture What is a good design? It is the design that at least does not have signs of “bad”.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Implementation Yaodong Bi. Introduction to Implementation Purposes of Implementation – Plan the system integrations required in each iteration – Distribute.
Alexander Serebrenik, Serguei Roubtsov, and Mark van den Brand D n -based Design Quality Comparison of Industrial Java Applications.
1 OO Design Novosoft, 2001 by V. Mukhortov. 2 OO Design Goals  Flexibility Changes must be localized  Maintainability Modules requiring changes can.
Ch:10 Component Level Design Unit 4. What is Component? A component is a modular building block for computer software Because components reside within.
Company Confidential – Do Not Duplicate 2 Copyright 2008 McLane Advanced Technologies, LLC S.O.L.I.D. Software Development Achieving Object Oriented Principles,
Component Basics CS6961 – Lecture 6 Nathan Dykman.
OODP Prudent OO Design. OODP-2 The Pillars of the Paradigm Abstraction Encapsulation Hierarchy –Association, Aggregation –Inheritance Polymorphism.
Advanced Principles II Principles of Object-Oriented Component Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this.
CSC 395 – Software Engineering Lecture 12: Reusability –or– Programming was Bjarne Again.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Introduction to SOLID Principles. Background Dependency Inversion Principle Single Responsibility Principle Open/Closed Principle Liskov Substitution.
CSSE 374: More GRASP’ing for Object Responsibilities
S.O.L.I.D. Software Development 12 January 2010 (Martin Verboon, Patrick Kalkman, Stan Verdiesen)
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.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Elements of OO Abstraction Encapsulation Modularity Hierarchy: Inheritance & Aggregation 4 major/essential elements3 minor/helpful elements Typing Concurrency.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Introduction What is detector simulation? A detector simulation program must provide the possibility of describing accurately an experimental setup (both.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Five design principles
Chapter 14 컴포넌트-수준 설계 Component-Level Design
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
Component Design Elaborating the Design Model. Component Design Translation of the architectural design into a detailed (class-based or module- based)
SOLID Design Principles
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Session 33 More on SOLID Steve Chenoweth Office: Moench Room F220 Phone: (812) Chandan Rupakheti Office: Moench.
1 Good Object-Oriented Design Radu Marinescu Lecture 3 Principles of Object-Oriented Design Part II 19 th November 2002.
1 OO Class Design PrinciplesStefan Kluth 3OO Class Design Principles 3.1Dependency Management 3.2The Copy Program 3.3Class Design Principles.
Principles of Package Design COMPOSE AT A HIGHER LEVEL OF ABSTRACTION.
1 Advanced Object- oriented Design – Principles CS320 Fall 2005.
1 Advanced Object-oriented Design – Principles and Patterns OO Design Principles.
Mantas Radzevičius ifm-2/2
Chapter 12 Object Oriented Design Principles
Software Architecture & Difference from Design
Chapter 12 Object Oriented Design Principles
CSE687 - Object Oriented Design class notes Survey of the C++ Programming Language Jim Fawcett Spring 2004.
Unfunded Liabilities: How Poor Package Design Drives Technical Debt and What You Can Do About It Allen C Smith, CLA Senior Systems Engineer, ATE.
Copyright © by Curt Hill
Software Engineering: A Practitioner’s Approach, 6/e Chapter 11 Component-Level Design copyright © 1996, 2001, 2005 R.S. Pressman & Associates, Inc.
Principles of Package Architecture
Object-Oriented Design
Design Tips.
Principles of Object-Oriented Design Part II
A (partial) blueprint for dealing with change
Principles of High-Level Design
Dependency Inversion principle
Some principles for object oriented design
Chapter 10 – Component-Level Design
Presentation transcript:

1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles 4.4Development Environment (Three more principles) 4.5Summary

2 OO Package Design PrinciplesStefan Kluth 4.1 Packages Introduction ● What is a package? – Classes are not sufficient to group code – Some classes collaborate dependencies – Some don't know each other ● Grouping related classes together seems natural – But how? – Dependencies between packages

3 OO Package Design PrinciplesStefan Kluth 4.1 Package ● A package is a group of classes ● Classes in a package are often compiled together into a library – but unit of compilation is mostly individual class ● A package is a unit for testing ● A package can be a releasable component – a CVS module

4 OO Package Design PrinciplesStefan Kluth 4.2 Packages in UML A package A package with classes shown inside A dependency between packages

5 OO Package Design PrinciplesStefan Kluth 4.2 Realisation GUI depends on AbsUI Associations exist between classes in GUI and AbsUI ServerStuff realises AbsUI, it is a concrete package An inheritance relationship exists between classes in AbsUI and ServerStuff AbsUI is an abstract package

6 OO Package Design PrinciplesStefan Kluth 4.3 Three Package Design Principles ● Reuse-Release Equivalency Principle ● Common Closure Principle ● Common Reuse Principle

7 OO Package Design PrinciplesStefan Kluth 4.3 Reuse-Release Equivalency Principle (REP) The unit of reuse is the unit of release Bob Martin It is about reusing software Reuseable software is external software, you use it but somebody else maintains it. There is no difference between commercial and non-commercial external software for reuse.

8 OO Package Design PrinciplesStefan Kluth 4.3 Reuse-Release Equivalency ● Expectations on external software – Documentation ● complete, accurate, up-to-date – Maintainance ● bugs will be fixed, enhancements will be considered – Reliability ● no major bugs ● no sudden changes ● can stay with proven versions (for a while)

9 OO Package Design PrinciplesStefan Kluth 4.3 Release Control ● Requirements for reuseable software – Put reuseable components into a package – Track versions of the package (CVS) – Assign release numbers to stable releases – Stable releases need release notes – Allow users to use older releases for a while ● The unit of reuse is the unit of release

10 OO Package Design PrinciplesStefan Kluth 4.3 REP Summary ● Group components (classes) for reusers ● Single classes are usually not reuseable – Several collaborating classes make up a package ● Classes in a package should form a reuseable and releaseable module – Module provides coherent functionality – Dependencies on other packages controlled – Requirements on other packages specified ● Reduces work for the reuser

11 OO Package Design PrinciplesStefan Kluth 4.3 Common Closure Principle (CCP) Classes which change together belong together Bob Martin Minimise the impact of change for the programmer. When a change is needed, it is good for the programmer if the change affects as few packages as possible, because of compile and link time and revalidation

12 OO Package Design PrinciplesStefan Kluth 4.3 From OCP to CCP ● OCP: Classes should be open for extension, but closed for modification – This is an ideal – Classes will be designed for likely kinds of changes ● Cohesion of closure for packages – Classes in a package should be closed to the same kinds of changes – Changes will be confined within few packages ● Reduces frequency of release of packages

13 OO Package Design PrinciplesStefan Kluth 4.3 CCP Summary ● Group classes with similar closure together – package closed for anticipated changes ● Confines changes to a few packages ● Reduces package release frequency ● Reduces work for the programmer

14 OO Package Design PrinciplesStefan Kluth 4.3 Commom Reuse Principle (CRP) Classes in packages should be reused together Bob Martin Packages should be focused, users should use all classes from a package CRP for packages is analogous to SRP for classes

15 OO Package Design PrinciplesStefan Kluth 4.3 Common Reuse ● Use of a package brings in all its dependencies ● When a user is only interested in a few classes of a package – the user code still depends on all dependencies of the package – the user code must be recompiled/relinked and retested after a new release of the package, even if the actually used classes didn't change ● CRP helps to avoid this situation

16 OO Package Design PrinciplesStefan Kluth 4.3 CRP Summary ● Group classes according to common reuse – avoid unneccessary dependencies for users ● Following the CRP often leads to splitting packages – Get more, smaller and more focused packages ● CRP analogous to SRP for classes ● Reduces work for the reuser

17 OO Package Design PrinciplesStefan Kluth 4.3 The Triad Triangle REP: Group for reusers CCP: Group for maintainer CRP: Split to get common reuse Unneeded releases Little reuser convenience Changes in many packages

18 OO Package Design PrinciplesStefan Kluth 4.4 The Development Environment ● Controlling relations between packages – Critical for large projects – Programming, compile and link time ● Three more package design principles – Acyclic Dependencies – Stable Dependencies – Stable Abstractions ● Other aspects of the development environment

19 OO Package Design PrinciplesStefan Kluth 4.4 The Acyclic Dependencies Principle (ACP) The dependency structure for packages must be a Directed Acyclic Graph (DAG) Stabilise and release a project in pieces Avoid interfering developers Morning after syndrome Organise package dependencies in a top-down hierarchy

20 OO Package Design PrinciplesStefan Kluth 4.4 Morning-After-Syndrome ● Not the one after an extended pub crawl ● You work on a package and eventually it works → you go home happy ● The next day your package stopped working! – A package you depend upon changed – Somebody stayed later or came in earlier ● When this happens frequently – Developers interfere with each other – Hard to stabilise and release

21 OO Package Design PrinciplesStefan Kluth 4.4 Dependencies are a DAG It may look complicated, but it is a DAG (Directed Acyclic Graph) Can exchange ObjyIO and RootIO

22 OO Package Design PrinciplesStefan Kluth 4.4 Dependency Cycles A cycle between Framework and ObjyIO Must develop together May need multipass link

23 OO Package Design PrinciplesStefan Kluth 4.4 ADP Summary ● Dependency structure of packages is a DAG ● Dependency cycles Morning-After-Syndrome ● Dependency hierarchy should be shallow ● Break cycles with – Abstract interfaces (DIP) – Splitting packages (CRP) – Reorganising packages

24 OO Package Design PrinciplesStefan Kluth 4.4 Stable Dependencies Principle (SDP) Dependencies should point in the direction of stability Stability:corresponds to effort required to change a package stable package hard to change within the project Stability can be quantified Robert Martin

25 OO Package Design PrinciplesStefan Kluth 4.4 Quantifying Stability A is a stable package, many other packages depend on it Responsible I = 0 A is unstable, it depends on many other packages Irresponsible I = 1 C a = # classes outside the package which depend on classes inside the package (incoming dependencies) C e = # classes outside the package which classes inside the package depend upon (outgoing dependencies) Instability I-Metric

26 OO Package Design PrinciplesStefan Kluth 4.4 SDP Example E depends on F, G and E. A depends on it. E is responsible and irresponsible. A is responsible for B, C and D. It depends on E, → irresponsible A is responsible for B, C, D and E. It will be hard to change E depends on A, F, G and H. It is irresponsible and will be easy to modify. Bad Good

27 OO Package Design PrinciplesStefan Kluth 4.4 SDP Summary ● Organise package dependencies in the direction of stability ● (In-) Stability can be quantified → I-Metric ● Dependence on stable packages corresponds to DIP for classes – Classes should depend upon (stable) abstractions or interfaces – These can be stable (hard to change)

28 OO Package Design PrinciplesStefan Kluth 4.4 Stable Abstractions Principle (SAP) Stable packages should be abstract packages. Unstable packages should be concrete packages. Stable packages contain high level design. Making them abstract opens them for extension but closes them for modifications (OCP). Some flexibility is left in the stable hard-to-change packages. Robert Martin

29 OO Package Design PrinciplesStefan Kluth 4.4 Quantifying Abstractness ● The Abstractness of a package can be quantified ● Abstractness A is defined as the fraction of abstract classes in a package. ● Corresponds to abstract classes – Abstract classes have at least one pure virtual member function – Abstract packages have at least one abstract class

30 OO Package Design PrinciplesStefan Kluth 4.4 Correlation of Stability and Abstractness ● Abstract packages should be responsible and independent (stable) – Easy to depend on ● Concrete packages should be irresponsible and dependent (unstable) – Easy to change

31 OO Package Design PrinciplesStefan Kluth 4.4 The A vs I Plot Abstractness A I Instability Main Sequence Abstract and unstable → probably useless Unstable and concrete → good Abstract and stable → good Stable and concrete → problematic, CLHEP, STL, database schema ok, not volatile

32 OO Package Design PrinciplesStefan Kluth 4.4 Distance from Main Sequence D- Metric D = | A+I-1 | Normalised so that D ∈ [0,1] Can use mean and standard deviation to set control limits Can find troublesome packages Concrete and stable packages like CLHEP or STL will have D ≃ 1

33 OO Package Design PrinciplesStefan Kluth 4.4 Examples from BaBar Offline code packages release (early 1999) Much of the BaBar code at the time was too concrete for its stability At least the problem was recognised...

34 OO Package Design PrinciplesStefan Kluth 4.4 SAP Summary ● Stable packages should be abstract ● In a large project packages should have a balance of Abstractness and Instability – Lie close to the main sequence in A-I-plot ● Metrics I and A help to quantify code quality ● Other metrics exist too – Code volume and code growth rate – Bug discovery and extinction rate

35 OO Package Design PrinciplesStefan Kluth 4.5 Mapping Packages on the Computer ● The BaBar example – Each package corresponds to a directory with flat structure under individual CVS control – Contains headers (.hh), code (.cc), documentation – GNUmakefile fragment for building and dependencies – Build target is a link library and possibly binaries – #include "package/class.hh" ● Works well... easy to understand

36 OO Package Design PrinciplesStefan Kluth 4.5 Object Oriented Design Summary ● Class Design Principles – Single Responsibility – Open-Closed – Liskov Substitution – Dependency Inversion – Interface Segregation ● Package Design Principles – Reuse-Release Equivalence – Common Closure – Common Reuse – Acyclic Dependencies – Stable Dependencies – Stable Abstractions