Advanced Principles II Principles of Object-Oriented Component Design Copyright  1998-2006 by Object Mentor, Inc All Rights Reserved Portions of this.

Slides:



Advertisements
Similar presentations
Software Engineering Key design concepts Design heuristics Design practices.
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
•7/12 /07 F-1 © 2010 T. Horton CS 4240 Principles of SW Design Packages in Java and UML.
Structured Design. 2 Design Quality – Simplicity “There are two ways of constructing a software design: One is to make it so simple that there are obviously.
1 Software Design Introduction  The chapter will address the following questions:  How do you factor a program into manageable program modules that can.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Stability and Volatility is Software Design H. Rahnama Tutorial in software engineering.
What is Software Design?  Introduction  Software design consists of two components, modular design and packaging.  Modular design is the decomposition.
Copyright Irwin/McGraw-Hill Software Design Prepared by Kevin C. Dittman for Systems Analysis & Design Methods 4ed by J. L. Whitten & L. D. Bentley.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
© Copyright 2011 John Wiley & Sons, Inc.
Fall 2007CS 225 Introduction to Software Design Chapter 1.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Spring 2009CS 225 Introduction to Software Design Chapter 1.
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
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Chapter 13 Starting Design: Logical Architecture and UML Package Diagrams.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
Object Oriented Analysis and Design Introduction.
An Introduction to Software Architecture
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.
Introduction to Software Design Chapter 1. Chapter Objectives  To become familiar with the software challenge and the software life cycle  To understand.
CSC 395 – Software Engineering Lecture 12: Reusability –or– Programming was Bjarne Again.
Software Design Deriving a solution which satisfies software requirements.
Systems Analysis and Design in a Changing World, 3rd Edition
L8 - March 28, 2006copyright Thomas Pole , all rights reserved 1 Lecture 8: Software Asset Management and Text Ch. 5: Software Factories, (Review)
Chapter 7 Software Engineering Introduction to CS 1 st Semester, 2015 Sanghyun Park.
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.
GRASP: Designing Objects with Responsibilities
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles.
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Connecting with Computer Science2 Objectives Learn how software engineering is used to create applications Learn some of the different software engineering.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
Design and Planning Or: What’s the next thing we should do for our project?
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
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.
1 Good Object-Oriented Design Radu Marinescu Lecture 3 Principles of Object-Oriented Design Part II 19 th November 2002.
+ Informatics 122 Software Design II Lecture 13 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
Basic Characteristics of Object-Oriented Systems
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 6.0.
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.
Metrics of Software Quality
Coupling and Cohesion 1.
Chapter 11 Object-Oriented Design
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
Objects First with Java
CSSSPEC6 SOFTWARE DEVELOPMENT WITH QUALITY ASSURANCE
Object-Oriented Design
Starting Design: Logical Architecture and UML Package Diagrams
Software Design Lecture : 8
An Introduction to Software Architecture
Principles of Object-Oriented Design Part II
Principles of High-Level Design
Logical Architecture & UML Package Diagrams
Presentation transcript:

Advanced Principles II Principles of Object-Oriented Component Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this material are Copyright © 1998, by Addison Wesley Longman,Inc. and have been reproduced here with permission.

2 Increasing Complexity Windows 95: 14,500,000 Windows NT: 35,000,000

3 Complexity and Failure (Software’s Chronic Crisis, Scientific American, September, 1994)

4 Complexity dilutes Productivity Because complexity of software can grow geometrically with size...

5 Coupling Coupling is the term used to describe the dependence of one software module upon another. When coupling is high, there are many dependencies between the modules. In a system with n modules, the coupling can be as high O(n 2 )

6 Coupling – Impact of Change The impact of making a change to a module is a function of its coupling. Every module that depends upon the changed module must be inspected, compiled, tested, and redeployed. Moreover, the transitive closure of modules that depend upon a changed module must be recompiled, re-tested, and redeployed. That transitive closure can be as high as O(n); And since there are n such closures in the system… (A system with a fully coupled architecture)

7 Dilution of Productivity As the application size grows, more and more effort is applied to dealing with coupled modules. At the knee of the curve more effort is applied to coupling than adding features. The effort expended to add new features drives the complexity upwards and drives the productivity downwards.

8 So… Project effort increases geometrically with project size. … Project size increases Exponentially with time.

9 Other costs of a highly coupled architecture Geometrically increasing compile time. Geometrically increasing unit test time. Componentization is infeasible. Making footprint and load-time issues unmanageable.

10 Barrier to Components As footprint and load time grows, the desire to break the software into individual components -- that can be independently built, tested, and deployed -- increases. However, componentization depends critically upon being able to create subsystems that are independent. So long as coupling is high, and dependency cycles are rampant, componentization will be infeasible ?

11 Faulty Architecture: Dependency Cycles A single cyclic dependency in an otherwise acyclic structure can dramatically increase coupling. Note that the red dependency forces module six to depend upon every other module in the system. Such dependencies have a tendency to creep in over time as the system is being maintained and enhanced. Especially during schedule crunches

12 The Solution Create a software architecture with well managed interdependencies.

13 Flattening the Geometric Curve Coupling need not increase as O(n 2 ). Tree structures have no cycles and reduced coupling to O(nlog n); Productivity decreases with the log, not the square, of the number of modules

14 Productivity Recaptured time See: Large Scale C++ Software Design by John Lakos.

15 Principles of Object Oriented Component Design What is a component? Components on Class Diagrams The Triad of Component Principles REP: The Reuse/Release Equivalency Principle CCP: The Common Closure Principle CRP: The Common Reuse Principle

16 Intro to Components Large systems of objects and classes would be overwhelming We have lots of small and simple classes A way must exist to deal with groups of classes Otherwise, it’s almost like building a sand castle from individual grains of sand “…the class is a necessary but insufficient vehicle for decomposition.” -- Grady Booch

17 What is a component A group of classes. Some of the classes are public. Some of the classes are private. A C++ “Namespace”. A Java “Package”. A DLL. A releasable component. The “Simple” Answer

18 Components on Class Diagrams Drawn as rectangle with a smaller rectangle above it. They can be drawn large with icons of classes and their interrelationships within them. Then the name should be in the “tab”. Also drawn as rectangle with two small rectangles on left. Looks like a file folder

19 Package Relationships We will discuss two relationships between components Dependency Realizes Packages do not stand alone and must interact with other packages

20 Dependency Structure Dependency structure of a n automated parking garage.

21 Realizes Components may be composed of abstract classes.Other packages may provide implementations for the abstract classes. This is drawn as a dashed line (like dependency) with an open, triangular arrowhead (like inheritance). The relationship is officially known as “realizes”, but means that the concrete package implements the abstract package’s interface(s). This is another kind of dependency.

22 Component Cohesion Principles REPReuse-release Equivalency Principle CCPCommon Closure Principle CRPCommon Reuse Principle

23 (REP) The Reuse/Release Equivalency Principle What do you expect from a supplier of reusable modules? The granule of reuse is the granule of release

24 Expectations Documentation. Accuracy. Maintenance. You expect the supplier to maintain the modules that you are reusing. Predictability. You expect that the module will not change out from under you. That you will be notified in advance of any changes That you will be given the option to use the old version.

25 Reusers Expect Release Control In order to get users to agree to reuse a module: You must bind the reusable classes together into components. Each component need to be tracked in a release system. Each component needs release numbers. Each release needs release notes. Users must be able to continue to use the older versions for a while. Thus, the granule of reuse is the granule of release. Version numbers and release tracking.

26 The granule of reuse is the granule of release. Single classes are seldom reusable They typically depend on other classes. They are not typically released alone. There are ramifications for component design The classes in a component should form both a releasable and a reusable module. This principle deals with a kind of cohesion.

27 REP Review What is the REP? Are reuse groupings coincidental? Is it primarily concerned with coupling or cohesion? How does this differ from more traditional ways of grouping components? REP: Group for reusers

28 (CCP) The Common Closure Principle Given an application to which changes need to be made: Do we want to change many components? Or as few as possible? Minimize the impact of change

29 Scaling up the OCP The open closed principle states that a class should be “open for extension but closed for modification.” This cannot be completely achieved. Thus, we design our classes to be closed to the most likely kinds of changes that we can foresee. That important class design consideration is also an important component design consideration.

30 Cohesion of Closure Classes within a component should be closed together. A component is cohesive if the classes within it are all closed to the same kinds of modifications. When this principle can be achieved, changes do not propagate through the system. Given a particular kind of change, either all of the classes within a package are closed to it, or they are all open to it.

31 Non-Propagation of Changes Changes focus upon one, or a very few packages. The rest of the packages remain unaffected. This greatly lessens the number of packages that are affected by a change, and reduces the frequency with which components must be released.

32 CCP and REP Sometimes these principles are in complete harmony The best of times Other times the two groupings may conflict somewhat. You can choose one to lean toward How much maintenance is expected? REP: Group for reusers CCP: Group for maintenance

33 CCP Review What does the CCP tell us to do? Why is this a good idea? How is the CCP different from the REP? Do the CCP and REP direct us more toward broad horizontal (technical) partitioning, or vertical (functional) partitioning?

34 (CRP) The Common Reuse Principle Classes within a component should be reused together Reuse creates a dependency upon the whole reused component. Reusable components are generally made of many collaborating classes.

35 Reusers Depend on the Whole Component When a new release of that component is created, the reuser must reintroduce it into existing applications. There is a cost for this And a risk Therefore, the user will want each component to be as focused as possible. If the component contains classes which the user does not make use of, then the user may be placed in the position of accepting the burden of a new release which does not affect any of the classes within the component that he is using.

36 Common Reuse Principle This is a principle that breaks up components. You will end up with some small, focused components. You’ll end up with some loose classes. Loose classes may be grouped with REP and CCP into more cohesive groups. Volatility should be considered. Given simply, the user should depend on the whole package. This is a scaled up version of Interface Segregation.

37 Reusable Components Have Many Collaborating Classes The relationships between those classes bind them together Placing them in separate components will create dependencies between those components.

38 Conflict in the Triad REP: Group for reusers CCP: Group for maintenance CRP: Split to avoid unneeded releases Will receive unneeded releases. Changes split among components Too little reuser convenience Where in this space does your package fall?

39 CRP Review What does the CRP tell us to do in component design? How is it different from the REP? How is it different from the CCP? Could you draw the triad, and label the corners? Place a well-known library or component in the triangular space, showing how the tradeoffs were made.

40 Package Cohesion Principles Summary REPGroup for convenience of (re)users CCPGroup for convenience of maintainers CRPSplit to prevent dependencies on partial packages

41 Principles of Component Coupling (ADP) The Acyclic Dependencies Principle. (SDP) The Stable Dependencies Principle. (SAP) The Stable Abstractions Principle. Metrics: Management vs. random walks. Packages and Directory Structures. Source code configuration systems. The larger the project, the more critical it is to manage the relationships between components

42 (ADP) The Acyclic Dependencies Principle Applications must be stabilized and released in pieces. Otherwise, the developers interfere with each other: The “Morning After” Syndrome. By carefully structuring components, the problem is avoided. The dependency structure for components must be a DAG.

43 The “Morning After” Syndrome You work till 5PM getting something working. But when you come back the next day… Your stuff doesn't work. Somebody stayed later than you did… … or came in earlier And this repeats, day after day after day… The engineers on a project step all over each other. Time to stabilize a release is unpredictable.

44 Dependency Structures The problem may be that the dependency structure of the project is poor, is not understood or is not respected. Changes are rippling through the system in several directions!

45 Well structured packages prevent this problem Components can be released. Users that aren’t ready for the release can continue to use the old versions. The developers can continue to modify components without affecting the users. Components are stabilized and then released internally Changes flow in one direction only Dependency Cycles ruin this scheme.

46 Well Structured Packages Prevents This Problem

47 In the garage system (prev page), we have a sane structure. We can stabilize and plan in a rational way. Now there is a change: When there is a problem, we just rang an alarm Now we realize we need to display a message The ‘alarm’ programmers aren’t aware of the DAG... How do package structure problems occur?

48 Dependency Cycles Ruin This Scheme The resulting structure is no longer a DAG.

49 Breaking the Cycle It’s once again a DAG. Structure and sanity return to our little world.

50 Cycles can also be broken by adding abstraction Imposing an abstract class can invert a dependency

51 Stable Dependencies Principle A component should only depend upon others that are more stable than itself Stability is a measure of the difficulty in changing a component What makes a component hard to change?

52 A Component with many dependents is “Responsible” Responsibility implies stability. Not free to change Irresponsibility implies instability. Free to change A Component that depends on many others is “Dependent”. Independence implies stability. Dependence implies instability. Stable Dependencies Principle

53 Depending in the direction of INstability This is a bad thing Component A depends in a direction of INstability. B is free to change. When B changes, changes can ripple up to A. Since A is not free to change, this will create a problem. We wish to depend in the direction of Stability Stable Dependencies Principle

54 Here, A is irresponsible and very dependent. B is responsible and independent. In this case, A is free to change on its own, and nothing in the system is impacted by the change. B is stable, and so it’s undesirable to change it. This is a healthy structure. Stable Dependencies Principle

55 Stable Dependencies Principle Stability can be measured Define I. Instability metric I = Ce / ( Ca + Ce) Ce = Efferent couplings Ca = Afferent couplings I = 1 / ( ) = 0.25 I = 0 I = 1

56 Stable Abstractions Principle The abstraction of a package should be in proportion to its stability If all packages are maximally stable, the system would be unchangable Some packages should be stable Those that encapsulate high-level policy These packages should be abstract Some packages should be instable Those that encapsulate low-level implementation details

57 Stable Abstractions Principle Abstractness of a package can be measured A = Na / N Na = number of abstract classes N = total number of classes

58 Analyzing Metrics Packages have degrees of abstraction versus stability Packages along the line from (0,1) to (1,0) have a good balance (0,1) (1,0) Main Sequence

59 Analyzing Metrics Abstractions without dependents are useless. Concretions with lots of dependents are painful. e.g. database schemae (0,1) (1,0) Main Sequence Zone of uselessness Zone of pain

60 Main Sequence (cont.) Distance from Main Sequence (normalized) D = | A + I - 1 | Design can be analyzed for conformance to main sequence D

61 Tools that Calculate the Metrics Smallworlds Headway Jdepend Depend.sh

62 Component and Directory Structures Our convention at Object Mentor, Inc. Each component is represented by a directory. All the.cc and.h files are placed in that directory. A library file (.a) is generated for that directory. Any documentation files should be included too Make file. The directory structure is generally flat. Nested packages are not impossible, but are rare. #include Written as # include “package/file.h”