Object-Oriented Design

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

1

Outline
From Analysis to Design Design Issues System Design Object Design Design patterns & Conclusion
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 2

Object-Oriented Design
Transforms OOA model into blueprint for software construction x Builds upon four essential design concepts
x

• • • •

Abstraction Information hiding Functional independence Modularity

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

3

Mapping OOA to OOD

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

4

Outline
From Analysis to Design Design Issues System Design Object Design Design patterns & Conclusion
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 5

Comparison of Conventional & OOD
Representation of module hierarchies x Specification of data definitions x Specification of procedural logic x Indication of end-to-end processing flow x Representation of object states and transitions x Definition of classes and hierarchies x Assignment of operations to classes x Detailed definition of operations x Specification of message connections x Identification of exclusive services
x
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 6

Design Issues for Modularity
Decomposability x Composability x Understandability x Continuity x Protection
x x x x x x

Linguistic modular units Few interfaces Small interfaces (weak coupling) Explicit interfaces Information hiding (no global data)
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 7

OOD Methodologies
The Booch Method x The Coad and Yourdon Method x The Jacobson Method x The Rumbaugh Method x The Wirfs-Brock Method
x

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

8

Booch Method
x

Architectural planning
• Cluster similar objects in separate architectural partitions. • Layer objects by level of abstraction. • Identify relevant scenarios. • Create a design prototype. • Validate the design prototype by applying it to usage scenarios.
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 9

Booch Method
x

Tactical design
• Define domain-independent policies. • Define domain specific policies. • Develop a scenario that describes the semantics of each policy. • Create a prototype of each policy. • Instrument and refine the prototype. • Review each policy.
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 10

Booch Method
x

Release planning
• Organize scenarios developed during OOA by priority. • Allocate corresponding architectural releases to the scenarios. • Design and construct each release incrementally. • Adjust goals and schedule of incremental release as required.

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

11

The Rumbaugh OMT
Perform system design x Conduct object design x Implement Control mechanisms x Adjust class structure to strengthen inheritance x Design messaging to implement the object relationships x Package classes and associations into modules
x

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

12

Outline
From Analysis to Design Design Issues System Design Object Design Design patterns & Conclusion
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 13

OOD Process Flow

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

14

System Design
x

Partition the analysis model into subsystems
• A subsystem is a package (collection) of classes and associations, events and constraints that are interrelated and have a small interface. • Usually identified by the services it provides.

Identify concurrencies x Allocate subsystems to processors and tasks x Choose a basic strategy for data management
x

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

15

System Design
Identify global resources and access control mechanisms x Design control mechanism for system x Determine how to handle boundary conditions. x Review & modify if necessary
x

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

16

System Design
Partition the Analysis Model
x x

Small number of subsystems,
• Partition subsystems to reduce complexity

Well-defined interface, services x Intra- (use) and inter- (minimize) communication x Achieve high Cohesion within a subsystem x Communication between subsystems: client/ server (one way) or peer-to-peer (two way)
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 17

Communication Models

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

18

System Design
Going towards High Cohesion

Cohesion
Coincidental x Logical x Temporal x Communication x Sequential x Functional x Data
x
Chapter 21 -- Assistance -- Magy Seif El-Nasr 19

February 1, 1998 R. A. Volz

System Design
Concurrency and subsystem Allocation Identify active objects (threads of control) x Where to allocate subsystems
x

• same processor? -- need concurrency control • independent processor ? -- may still need concurrency control
x

Allocation and design issues:
• performance requirements. • costs • overheads and efficiency
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 20

Concurrency Example
DB access • • • • • • DB access Database

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

21

Concurrency
x

Ada -- Use tasks task type DB_access is … end; type dba is access DB_access; a, b: dba; … a := new DB_access; b:= new DB_access; …

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

22

Concurrency
x

Java -- Use threads class dbAccess extends thread{… public void run () { …} … new dbAccess.start(); new dbAccess.start(); }
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 23

Some Concurrency Issues
x

Mutual exclusion of shared objects
• Two objects should not be able to write to the same shared object at the “same time.”

x

Communication
• Allow messages to be sent between objects. When is an object ready to receive a message?

x

Synchronization
• Ensure that two or more objects are at known points at the same time.
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 24

Data Management
Generally refers to shared objects x Concurrency controls essential x Often refers to data to have a permanence beyond scope of program x Issues
x

• Infrastructure for access and storage • Management of data
x

Often look for interfaces to existing support subsystems
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 25

System design
Resource Management
x

Resources: External entities vs. abstractions
• E.g., disk, processor, comm line • Databases, objects, interfaces

x

Guardian object:
• Keeper of the resource • Controlling access to the resource • Moderating conflicts for requests

x

Language support can vary widely
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 26

System design
Human-Computer Interface
x x

Inputs: user scenarios and roles Identify command hierarchy (menu bars, popups, windows, interactive controls, ...) Reuse existing support tools whenever possible
• So all that is needed are objects that have appropriate characteristics of problem domain
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 27

x

Intersubsystem Communication
x

Create a table for each contract

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

28

Subsystem Collaboration Graph
x

List each request made by a collaborator

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

29

Outline
From Analysis to Design Design Issues System Design Object Design Design patterns & Conclusion
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 30

Object Design

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

31

Key Object Characteristics
(Available from Analysis)
Object name (or name of class of objects) x Description x Services provided or functions x How created x How invoked x Shared resources x Communication
x

• With whom? • Interfaces
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 32

Object Design
Object Internals
x

Protocol description
• List each message type the object can receive, e.g., • MESS(motion sensor): read RET id, status

x

Implementation description
• • • • Spec. of object’s name and reference to class Spec. of private data encapsulated Procedural description of each operation Specification of control structures
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 33

Use a PDL to Describe Object
PACKAGE program_component_name IS

type specification of data objects … Proc specifications of related operations
PRIVATE

data structure details for object types
PACKAGE BODY program_component_name IS

PROC operation: (interface specification) IS … PROC operation: (interface specification) IS
END program_component_name
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 34

High Level Sensor PDL
PACKAGE sensor IS

TYPE sensor_status IS (ON | OFF) TYPE sensor_id, alarm_char PROC read, set, test PRIVATE sensor_id, IS STRING LENGTH (8) alarm_char DEFINED threshold, sig_type, sig_level IS INTEGER
PACKAGE BODY sensor IS

TYPE update_rate IS INTEGER PROC read (sensor_id, sensor_status: OUT) ...
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 35

Object Design
Steps done in object design
x

Detail object attributes and operations Review object-relationship model Describe operations and transitions using PDLs.
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 36

x

x

Outline
From Analysis to Design Design Issues System Design Object Design Design patterns & Conclusion
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 37

Design Patterns
An abstraction that conveys meaning about a class’s applicability. x pattern template
x

Naming -- choose to aid search x Two different mechanisms
x

• • • •

Name : (applicability and intent) Problem description: (env. and conditions) Characteristics Consequences

• is-a (inheritance) -- a basis for new subclasses • has-a (composition) - ensemble

February 1, 1998 R. A. Volz

Chapter 21 -- Assistance -- Magy Seif El-Nasr

38

What next ?
From Design to implementation x Success of complex projects relies more on the design architecture rather than the implementation. So SW Eng. stresses OOA and OOD x If you have a good and complete design, implementation should be straightforward x Nevertheless, language choice does have an influence.
x
February 1, 1998 R. A. Volz Chapter 21 -- Assistance -- Magy Seif El-Nasr 39