271
Object Oriented Object Oriented Analysis and Design Analysis and Design using UML using UML

Object Oriented Analysis and Design using UML. L19-Design

Embed Size (px)

Citation preview

Page 1: Object Oriented Analysis and Design using UML. L19-Design

Object Oriented Analysis and Object Oriented Analysis and Design using UMLDesign using UML

Page 2: Object Oriented Analysis and Design using UML. L19-Design

L19-Design

Page 3: Object Oriented Analysis and Design using UML. L19-Design

Goals

• The object-oriented design process.

• Object-oriented design axioms and corollaries.

• Design patterns.

Page 4: Object Oriented Analysis and Design using UML. L19-Design

Object-Oriented Design Process in the Unified Approach

Continuos testing

OO DesignApply design

axiomsDesign classes,

methods,attributes, and

associations

User satisfactionand usability test

based on use casesRefine UML

Classdiagrams

Designview/

accesslayers andprototype

Page 5: Object Oriented Analysis and Design using UML. L19-Design

Why bother with formal design?

• Why do we need design notation?• Why do we need to struggle with formal legalistic

English• Why not just think about it and then start coding?

Answer:• Communication• Clarity• Different conceptual level

Page 6: Object Oriented Analysis and Design using UML. L19-Design

Levels of Abstraction

Architecture

Design

Implementation

while (true) doc := c - 1;d := d + 1;if c < 0 goto continue;

continue: ...

while (true) doc := c - 1;d := d + 1;if c < 0 goto continue;

continue: ...

Page 7: Object Oriented Analysis and Design using UML. L19-Design

THE DESIGN WORKFLOW

Page 8: Object Oriented Analysis and Design using UML. L19-Design

The design workflow

• The purpose in design is to specify fully how the

functionality will be implemented.

• Design involves will be implemented.

• Design involves merging in technical solutions from

the solution domain ( class libraries,persistence

mechanisms, etc.) to provide a model of the system (the

design model) that can actually be implemented.

Page 9: Object Oriented Analysis and Design using UML. L19-Design

Design artifacts - metamodel

• These subsystems are components that can contain many different types of modeling elements.

• Design we put much more emphasis on interfaces.

• Interfaces, therefore have a strong architectural role in

design and we will spend quite a lot of time looking for

and modeling, key interfaces. Contd…

Page 10: Object Oriented Analysis and Design using UML. L19-Design

Design artifacts - metamodel• The design model is based on the analysis model and can be

considered to be just a refinement and elaboration thereof.

Contd…

Analysis Model

Design Model

Conceptual

model

Physical

model

<<trace>>

Page 11: Object Oriented Analysis and Design using UML. L19-Design

Design artifacts - metamodel• Design models must include implementation details.• Design models are made up of

Design subsystems Design classes Interfaces Use case realization-design A deployment diagram

• One of the key artifacts that we produce in design are interfaces.

• These allow us to decouple our system into subsystems that can be developed in parallel.

Page 12: Object Oriented Analysis and Design using UML. L19-Design

Artifacts trace relationships

<<trace>>

Analysis package

Analysis class

Design class

<<interface>>interface

Design subsystem

Use case realization-Analysis

Use case realization -design

<<trace>>

<<trace>>

0..*

0..*

0..*

0..*

1

1 1

Page 13: Object Oriented Analysis and Design using UML. L19-Design

Should we maintain two models?• Modeling tool would be able to give either an analysis view of

that model or a design view.

. Strategy Consequences

1 Take the analysis model and refine in into a design model

we have a single design model, but we have lost the analysis view

2 Take the analysis model, refine it into a design model and use a modeling tool to recover an “analysis view”

We have a single design model, but the analysis view recovered by the modeling tool might not be satisfactory

3 Freeze the analysis model at some point in the Elaboration phase-refine a copy of the analysis model into a design model

We have two models, but they are out of step

4 Maintain two separate models-an analysis model and a design model

We have two models-they are in step, but there is a maintenance burden.

Page 14: Object Oriented Analysis and Design using UML. L19-Design

Should we maintain two models?• keep an analysis model for large complex, or strategic

systems.

• They are valuables for• Introducing new people to the project

• Understanding the system months or years after delivery

• Understanding how the system satisfies user requirements.

• Providing requirements traceability.

• Planning maintenance and enhancements

• Understanding the logical architecture of the system

• Outsourcing the construction of the system

Page 15: Object Oriented Analysis and Design using UML. L19-Design

Should we maintain two models?• We should preserve an analysis view for any system

that is large, complex, strategic, or potentially long-lived.

• If the system is small (say , less than 200 design

classes) then the design model itself is small enough to

be understandable, so a separate analysis model may

not be needed.

• It is wise to remember that many systems long outlive

their projected life span.

Page 16: Object Oriented Analysis and Design using UML. L19-Design

Design workflow detail

• The main participants in design are the • Architect

• The use case engineer

• And the component engineer.

Page 17: Object Oriented Analysis and Design using UML. L19-Design

OO Design Process• 1. Apply design axioms to design classes, their attributes,

methods, associations, structures, and protocols.• 1.1. Refine and complete the static UML class diagram (object

model) by adding details to the UML class diagram. This step consists of the following activities:

• 1.1.1. Refine attributes.

– 1.1.2. Design methods and protocols by utilizing a UML activity diagram to represent the method's algorithm.

– 1.1.3. Refine associations between classes (if required).

– 1.1.4. Refine class hierarchy and design with inheritance (if required).

• 1.2. Iterate and refine again.

Page 18: Object Oriented Analysis and Design using UML. L19-Design

OO Design Process (Con’t)

• 2. Design the access layer • 2.1. Create mirror classes. For every business class identified and

created, create one access class.

– 2.2. define relationships among access layer classes.

– 2.3. Simplify the class relationships. The main goal here is to eliminate redundant classes and structures.

• 2.3.1. Redundant classes: Do not keep two classes that perform similar translate request and translate results activities. Simply select one and eliminate the other.

• 2.3.2. Method classes: Revisit the classes that consist of only one or two methods to see if they can be eliminated or combined with existing classes.

– 2.4. Iterate and refine again.

Page 19: Object Oriented Analysis and Design using UML. L19-Design

OO Design Process (Con’t)

– 3. Design the view layer classes. – 3.1. Design the macro level user interface, identifying view

layer objects.

– 3.2. Design the micro level user interface, which includes these activities:

• 3.2.1. Design the view layer objects by applying the design axioms and corollaries.

• 3.2.2. Build a prototype of the view layer interface.

– 3.3. Test usability and user satisfaction (Chapters 13 and 14).

– 3.4. Iterate and refine.

– 4. Iterate and refine the preceding steps. Reapply the design axioms and, if needed, repeat the preceding steps.

Page 20: Object Oriented Analysis and Design using UML. L19-Design

Object-Oriented Design

Axioms, Theorems and Corollaries

• An axiom is a fundamental truth that always is observed to be valid and for which there is no counterexample or exception.

• A theorem is a proposition that may not be self-evident but can be proven from accepted axioms.

Page 21: Object Oriented Analysis and Design using UML. L19-Design

Axioms, Theorems and Corollaries (Con’t)

• A Corollary is a proposition that follows from an axiom or another proposition that has been proven.

Page 22: Object Oriented Analysis and Design using UML. L19-Design

Design Axioms

• Axiom 1 deals with relationships between system components (such as classes, requirements, software components).

• Axiom 2 deals with the complexity of design.

Page 23: Object Oriented Analysis and Design using UML. L19-Design

Axioms

• Axiom 1. The independence axiom. Maintain the independence of components.

• Axiom 2. The information axiom. Minimize the information content of the design.

Page 24: Object Oriented Analysis and Design using UML. L19-Design

Occam's Razor

• The best theory explains the known facts with a minimum amount of complexity and maximum simplicity and straightforwardness.

Page 25: Object Oriented Analysis and Design using UML. L19-Design

Corollaries

• Corollary 1. Uncoupled design with less information content.

• Corollary 2. Single purpose. Each class must have single, clearly defined purpose.

• Corollary 3. Large number of simple classes. Keeping the classes simple allows reusability.

Page 26: Object Oriented Analysis and Design using UML. L19-Design

Corollaries (Con’t)

• Corollary 4. Strong mapping. There must be a strong association between the analysis's object and design's object.

• Corollary 5. Standardization. Promote standardization by designing interchangeable components and reusing existing classes or components.

Page 27: Object Oriented Analysis and Design using UML. L19-Design

Corollaries (Con’t)

• Corollary 6. Design with inheritance. Common behavior (methods) must be moved to superclasses.

• The superclass-subclass structure must make logical sense.

Page 28: Object Oriented Analysis and Design using UML. L19-Design

Coupling and Cohesion

• Coupling is a measure of the strength of association among objects.

• Cohesion is interactions within a single object or software component.

Page 29: Object Oriented Analysis and Design using UML. L19-Design

Tightly Coupled Object

E

IHG

D

A B C

F

Page 30: Object Oriented Analysis and Design using UML. L19-Design

Corollary 1- Uncoupled Design with Less Information Content

• The main goal here is to maximize objects (or software components) cohesiveness.

Page 31: Object Oriented Analysis and Design using UML. L19-Design

Corollary 2 - Single Purpose• Each class must have a

purpose, as was explained !

• When you document a class, you should be able to easily explain its purpose in a sentence or two.

Page 32: Object Oriented Analysis and Design using UML. L19-Design

Corollary 3- Large Number of Simpler Classes, Reusability

• A great benefit results from having a large number of simpler classes.

• The less specialized the classes are, the more likely they will be reused.

Page 33: Object Oriented Analysis and Design using UML. L19-Design

Corollary 4. Strong Mapping

• As the model progresses from analysis to implementation, more detail is added, but it remains essentially the same.

• A strong mapping links classes identified during analysis and classes designed during the design phase.

Page 34: Object Oriented Analysis and Design using UML. L19-Design

Corollary 5. Standardization

• The concept of design patterns might provide a way for standardization by capturing the design knowledge, documenting it, and storing it in a repository that can be shared and reused in different applications.

Page 35: Object Oriented Analysis and Design using UML. L19-Design

Corollary 6. Designing with Inheritance

• Say we are developing an application for the government that manages the licensing procedure for a variety of regulated entities.

• Let us focus on just two types of entities: motor vehicles and restaurants.

Page 36: Object Oriented Analysis and Design using UML. L19-Design

Designing With Inheritance (Con’t)

MotorVehicle

PrivateVehicle CommercialVehicle

Restaurant

Page 37: Object Oriented Analysis and Design using UML. L19-Design

Designing With Inheritance (Con’t)

MotorVehicle

PrivateVehicle CommercialVehicle

Restaurant

License

Page 38: Object Oriented Analysis and Design using UML. L19-Design

Six Months Later

"What about coffee wagons, food trucks, and ice cream vendors? We're planning on licensing them as both restaurants and motor vehicles."

Page 39: Object Oriented Analysis and Design using UML. L19-Design

Designing With Inheritance Weak Formal Class

• MotorVehicle and Restaurant classes do not have much in common.

• For example, of what use is the gross weight of a diner or the address of a truck?

Page 40: Object Oriented Analysis and Design using UML. L19-Design

Designing With Inheritance (Con’t)

MotorVehicle

PrivateVehicle

FoodTruck

CommercialVehicle

Restaurant

Page 41: Object Oriented Analysis and Design using UML. L19-Design

Designing With Inheritance (Con’t)

MotorVehicle

PrivateVehicle

FoodTruck

CommercialVehicle Restaurant

Page 42: Object Oriented Analysis and Design using UML. L19-Design

Achieving Multiple Inheritance using Single Inheritance Approach

MotorVehicle

PrivateVehicle

FoodTruck

CommercialVehicle

Restaurant

Page 43: Object Oriented Analysis and Design using UML. L19-Design

Avoid Inheriting Inappropriate Behaviors

You should ask the following questions:

I. Is the subclass fundamentally similar to its superclass? or,

II. Is it entirely a new thing that simply wants to borrow some expertise from its superclass?

Page 44: Object Oriented Analysis and Design using UML. L19-Design

Summary• We studied the object-oriented design

process and axioms.

• The two design axioms are– Axiom 1. The independence axiom.

Maintain the independence of components.– Axiom 2. The information axiom.

Minimize the information content of the design.

Page 45: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)• The six design corollaries are

– Corollary 1. Uncoupled design with less information content.

– Corollary 2. Single purpose.– Corollary 3. Large number of simple classes.– Corollary 4. Strong mapping.– Corollary 5. Standardization.– Corollary 6. Design with inheritance.

Page 46: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• We also studied the concept of design patterns, which allow systems to share knowledge about their design.

Page 47: Object Oriented Analysis and Design using UML. L19-Design

Designing Classes

Object-Oriented Systems DevelopmentObject-Oriented Systems Development:

Using the Unified Modeling LanguageUsing the Unified Modeling Language

Page 48: Object Oriented Analysis and Design using UML. L19-Design

Goals

• Designing classes.

• Designing protocols and class visibility.

• Defining attributes.

• Designing methods.

Page 49: Object Oriented Analysis and Design using UML. L19-Design

OO Design Philosophy

• The first step in building an application should be to design a set of classes, each of which has a specific expertise and all of which can work together in useful ways.

Page 50: Object Oriented Analysis and Design using UML. L19-Design

Designing Class: the Process1. Apply design axioms to design classes, their attributes, methods,

associations, structures, and protocols. 1.1. Refine and complete the static UML class diagram (object model)

by adding details to that diagram. 1.1.1. Refine attributes.

1.1.2. Design methods and the protocols by utilizing a UML activity diagram to represent the method's algorithm..

1.1.3. Refine the associations between classes (if required).

1.1.4. Refine the class hierarchy and design with inheritance (if required).

1.2. Iterate and refine again.

Page 51: Object Oriented Analysis and Design using UML. L19-Design

Design class notation

<<entity>> Bank Account {authour=Jim,status=tested}

-number:string intialization value-Owner:string-balance:double =0.0

+Create(theNumber;String,theOwner:string)+depositor(amount:double)+withdraw(amount:double) +getNumber():string+getOwner();string+getBalance:double class scope operation(underlined)

Name compartment

class name stereotype tagged value

operation compartment

Attribute compartment

Visibility adornment

Page 52: Object Oriented Analysis and Design using UML. L19-Design

class Classwithattributes

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

Inv oice

- administrator: String+ amount: double = 5000+ customer: String+ date: Date = Current date+ specification: String

Page 53: Object Oriented Analysis and Design using UML. L19-Design

Classes

• In analysis modeling only the following needs to be shown:

Class name;

key attributes;

key operations

stereotypes(if they have any business significance)

Page 54: Object Oriented Analysis and Design using UML. L19-Design

Name compartment

Class name is in UpperCamelcase Special symbols such as punctuation marks,

dashes,underscores,ampersands,hashes, and slashes are always avoided andcan lead to unexpected cnsequences when code or Html/Xml documentation is generated from the model.

Avoid abbreviations at all costs Domain specific acronyms can be used(eg. CRM-

Customer Relationship Management)

Page 55: Object Oriented Analysis and Design using UML. L19-Design

Attribute Component

• Attributes are named in lowerCamelCase-Starting with a lowercase letter and then mixed upper-and lowercase.

visibilityname:type[multiplicity]=initialValue

Contd…

Page 56: Object Oriented Analysis and Design using UML. L19-Design

Visibility

• Visibility controls access to the features of a class.

+ ->Public visibility- ->Private visibility

# ->protected visibility

~ -> package visibility

Contd…

Page 57: Object Oriented Analysis and Design using UML. L19-Design

Type• The UML specification defines four primitive

types that are used in the UML specification itself.

Integer -A whole number UnlimitedNatural -A whole number>=0 infinity is shown as * Boolean –true or false String – A sequence of charecters

OCL(object constraint language is a formal language for expressing constraints in UML modules; and defines standard operations for the UML primitive types except UnlimitedNatural

and adds a new type called Real contd……

Page 58: Object Oriented Analysis and Design using UML. L19-Design

Initial value

• The initialvalue allows you to specify the value an attribute will take when an object is instantiated from the class.It helps to ensure that objects of the class are always created in a valid and useful state.

Page 59: Object Oriented Analysis and Design using UML. L19-Design

Advanced attribute syntax

• The specification of an attribute can be extended by postfixing the attribute with tagged values,for example,

<<sterotype>> attribute{tag1=value1,tag2=value2,….}

address{addedby=“jimarlow”,dateAddd=“20MAR2004”}

Page 60: Object Oriented Analysis and Design using UML. L19-Design

Operation compartment

An operation signature comprises its name,the type of all its parameters,and its return type.

Operations are named in lowerCamelCase.Format:

direction parameterName:parameterType=defaultValue

Page 61: Object Oriented Analysis and Design using UML. L19-Design

Parameter direction

in p1:Integer - The operation uses p1 as an input parameter and p1 is not changed by the operation

inout p2:integer - The operation accepts p2 as an input/output parameter and p2 may be changed by the operation.

Out p3:integer -The operation uses p3 as an output parameter and p3 may be changed by the operation.

return p4:integer-The operation uses p4 as a return parameter and returns p4 as one of its return values

contd….

Page 62: Object Oriented Analysis and Design using UML. L19-Design

Parameter direction (contd..)

• In UML return parameter direction allows you to model situations where an operation has more than one return value.

Eg:maxMin(in a:integer,in b:integer):integer,integer

Page 63: Object Oriented Analysis and Design using UML. L19-Design

Parameter default values

• An operation parameter can be given a default value.

Eg:drawCircle(origin:Point=Point(0,0),radius:integer)

drawSquare(origin:Point=Point(0,0),size:Dimension)

contd…….

Page 64: Object Oriented Analysis and Design using UML. L19-Design

class ClassWithAttributesandOperations

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

EA 6.5 Unregistered Trial Version EA 6.5 Unregistered Trial Version

CarAttOp

- data: car+ direction: String+ registrationNumber: String+ speed: double

+ drive(direction :String, speed :int) : void+ getData() : car

Page 65: Object Oriented Analysis and Design using UML. L19-Design

• public class CarAttOp {• private car data;• public String direction;• public String registrationNumber;• public double speed;• public CarAttOp(){• }• public void finalize() throws Throwable {• }• /**• * • * @param direction• * @param speed• */• public void drive(String direction, int speed){• }• public car getData(){• return null;• }• }

Page 66: Object Oriented Analysis and Design using UML. L19-Design

Query operations

• Each operation has a property called isQuery. If this property is set to true in the modelling tool,the operation is a query operation.

Page 67: Object Oriented Analysis and Design using UML. L19-Design

Scope• Instance scope attributes and

operations belong to,or operate on,specific objects.

• Class scope attributes and operations belong to, or operate on, the whole class of objects.

BankAccount-accountNumber:String-count:int=0+create(accNumber:string)+getAccountNumber:string-incrementCount()+decrementCount()+getCount():int

Class scope

(underlined)

Instance scope

Page 68: Object Oriented Analysis and Design using UML. L19-Design

Object Construction and destruction

• Constructors are a design consideration and are generally not shown on analysis models.

BankAccount+create(accNumber:string)

BankAccount+BankAccount(accNumber:string)

Generic constructor name Java/C#/C++ standard

Page 69: Object Oriented Analysis and Design using UML. L19-Design

Desructors

• Destructors are special operations that “clean up” when objects are destroyed.

• Different languages follow different algorithms for clean up.

• In java “Garbage Collection”

Page 70: Object Oriented Analysis and Design using UML. L19-Design

Class Visibility• In designing methods or attributes for

classes, you are confronted with two issues. – One is the protocol, or interface to the

class operations and its visibility; – and how it should be implemented.

Page 71: Object Oriented Analysis and Design using UML. L19-Design

Private (internal) Protocol

Protected Protocol

Public Protocol

Messages

Sub class

• Public protocols define the functionality and external messages of an object, while private protocols define the implementation of an object.

Class Visibility (Con’t)

Page 72: Object Oriented Analysis and Design using UML. L19-Design

Private Protocol (Visibility)

• A set of methods that are used only internally.

• Object messages to itself.

• Define the implementation of the object (Internal).

• Issues are: deciding what should be private.– What attributes– What methods

Page 73: Object Oriented Analysis and Design using UML. L19-Design

Protected Protocol (Visibility)

• In a protected protocol, subclasses can use the method in addition to the class itself.

• In private protocols, only the class itself can use the method.

Page 74: Object Oriented Analysis and Design using UML. L19-Design

Public Protocol (Visibility)

• Defines the functionality of the object

• Decide what should be public (External).

Page 75: Object Oriented Analysis and Design using UML. L19-Design

Guidelines for Designing Protocols

• Good design allows for polymorphism.

• Not all protocols should be public, again apply design axioms and corollaries.

Page 76: Object Oriented Analysis and Design using UML. L19-Design

Guidelines for Designing Protocols (Con’t)

• The following key questions must be answered:– What are the class interfaces and protocols?– What public (external) protocol will be used or

what external messages must the system understand?

Page 77: Object Oriented Analysis and Design using UML. L19-Design

Questions (Con’t)

– What private or protected (internal) protocol will be used or what internal messages or messages from a subclass must the system understand?

Page 78: Object Oriented Analysis and Design using UML. L19-Design

Attribute Types

• The three basic types of attributes are:– 1. Single-value attributes.– 2. Multiplicity or multivalue attributes.– 3. Reference to another object, or instance

connection.

Page 79: Object Oriented Analysis and Design using UML. L19-Design

Designing Methods and Protocols

• A class can provide several types of methods:– Constructor. Method that creates instances

(objects) of the class.– Destructor. The method that destroys

instances.– Conversion method. The method that

converts a value from one unit of measure to another.

Page 80: Object Oriented Analysis and Design using UML. L19-Design

Designing Methods and Protocols (Con’t)

– Copy method. The method that copies the contents of one instance to another instance.

– Attribute set. The method that sets the values of one or more attributes.

– Attribute get. The method that returns the values of one or more attributes.

Page 81: Object Oriented Analysis and Design using UML. L19-Design

Designing Methods and Protocols (Con’t)

– I/O methods. The methods that provide or receive data to or from a device.

– Domain specific. The method specific to the application.

Page 82: Object Oriented Analysis and Design using UML. L19-Design

Five Rules For Identifying Bad Design

• I. If it looks messy then it's probably a bad design.

Page 83: Object Oriented Analysis and Design using UML. L19-Design

Five Rules For Identifying Bad Design (Con’t)

• II. If it is too complex then it's probably a bad design.

Page 84: Object Oriented Analysis and Design using UML. L19-Design

Five Rules For Identifying Bad Design (Con’t)

• III. If it is too big then it's probably a bad design.

Page 85: Object Oriented Analysis and Design using UML. L19-Design

Five Rules For Identifying Bad Design (Con’t)

• IV. If people don't like it then it's probably a bad design.

Page 86: Object Oriented Analysis and Design using UML. L19-Design

Five Rules For Identifying Bad Design (Con’t)

• V. If it doesn't work then it's probably a bad design.

Page 87: Object Oriented Analysis and Design using UML. L19-Design

Avoiding Design Pitfalls

• Keep a careful eye on the class design and make sure that an object's role remains well defined.

• If an object loses focus, you need to modify the design.

• Apply Corollary 2 (single purpose).

Page 88: Object Oriented Analysis and Design using UML. L19-Design

Avoiding Design Pitfalls (Con’t)• Move some functions into new classes

that the object would use.

• Apply Corollary 1 (uncoupled design with less information content).

• Break up the class into two or more classes.

• Apply Corollary 3 (large number of simple classes).

Page 89: Object Oriented Analysis and Design using UML. L19-Design

Summary• This chapter concentrated on the first

step of the object-oriented design process, which consists of applying the design axioms and corollaries to design classes, their attributes, methods, associations, structures, and protocols; then, iterating and refining.

Page 90: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• Object-oriented design is an iterative process.

• Designing is as much about discovery as construction.

• Do not be afraid to change a class design, based on experience gained, and do not be afraid to change it a second, third, or fourth time.

Page 91: Object Oriented Analysis and Design using UML. L19-Design

Designing Architecture

Layered Architecture

Page 92: Object Oriented Analysis and Design using UML. L19-Design

Goals

• Object storage and persistence.

• Database management systems and their technology.

• Client-server computing.

• Distributed databases.

• Distributed object computing.

Page 93: Object Oriented Analysis and Design using UML. L19-Design

Goals (Con’t)

• Object-oriented database management systems.

• Object-relational systems.

• Designing access layer objects.

Page 94: Object Oriented Analysis and Design using UML. L19-Design

Introduction

• A database management system (DBMS) is a collection of related data and associated programs that access, manipulate, protect and manage data.

Page 95: Object Oriented Analysis and Design using UML. L19-Design

What’s the purpose of DBMS

• The main purpose of a DBMS is to provide a reliable, persistent data storage facility,and mechanism for efficient and convenient data access and retrieval.

Page 96: Object Oriented Analysis and Design using UML. L19-Design

Persistence (review)• Persistence is defined as objects that

outlive the programs which created them.

• Persistent object stores do not support query or interactive user interface facilities, as found in a fully supported DBMS or OODBMS.

Page 97: Object Oriented Analysis and Design using UML. L19-Design

Object Storage and Persistence• Atkinson et al. describe six broad

categories for the lifetime of data: – 1. Transient results to the evaluation of

expressions.– 2. Variables involved in procedure

activation (parameters and variables with a localized scope).

– 3. Global variables and variables that are dynamically allocated.

Page 98: Object Oriented Analysis and Design using UML. L19-Design

Object Storage and Persistence (Con’t)

– 4. Data that exist between the executions of a program.

– 5. Data that exist between the versions of a program.

– 6. Data that outlive a program.

Page 99: Object Oriented Analysis and Design using UML. L19-Design

Database Management Systems

• A DBMS is a set of programs that enable the creation and maintenance of a collection of related data.

• DBMS have a number of properties that distinguish them from the file-based data management approach.

Page 100: Object Oriented Analysis and Design using UML. L19-Design

Database system Vs. File System.

E ngineering

A ccounting

M arke ting

A ccounting

SalesAccountsEmployeeInventoryCustomer

Parts

D atabase

D B M S

M arketing

E ngineering P arts

C ustom er

S ales

Inventory

A ccounts

F ile System

A D atabase S ystem

Page 101: Object Oriented Analysis and Design using UML. L19-Design

Database Models

• A database model is a collection of logical constructs used to represent the data structure and data relationships within the database.

• Hierarchical Model– Network Model– Relational Model

Page 102: Object Oriented Analysis and Design using UML. L19-Design

Hierarchical model

M otor V eh ic le

Truck CarBus

• The hierarchical model represents data as a single-rooted tree.

Page 103: Object Oriented Analysis and Design using UML. L19-Design

Network model

Custom er Soup

O rder

• A network database model is similar to a hierarchical database, with one distinction.

• Unlike the hierarchical model, a network model's record can have more than one parent.

Page 104: Object Oriented Analysis and Design using UML. L19-Design

Relational Model

• Of all the database models, the relational model has the simplest, most uniform structure and is the most commercially widespread.

Page 105: Object Oriented Analysis and Design using UML. L19-Design

Relational Database (Con’t)

S oup N am eS oup-ID P rice

Soup Table

N am eC ust-ID A ddress P hone #

Customer Table

C ust-IDS oup-ID Q TY

Order Table

O rder-IDK ey

K eyK ey

Fore ignK eys

Page 106: Object Oriented Analysis and Design using UML. L19-Design

What is a schema and metadata?

• The schema, or metadata, contains a complete definition of the data formats, such as the data structures, types, and constraints.

Page 107: Object Oriented Analysis and Design using UML. L19-Design

Schema (Con’t)

• In an object-oriented DBMS, the schema is the collection of class definitions.

• The relationships among classes (such as super/sub) are maintained as part of the schema.

Page 108: Object Oriented Analysis and Design using UML. L19-Design

Database Definition Language (DDL)

• A database definition language (DDL) is used to describe the structure of and relationships between objects stored in a database.

Page 109: Object Oriented Analysis and Design using UML. L19-Design

Data Manipulation Language (DML)

• Once data is stored in a database, there must be a way to get it, use it, and manipulate it.

• DML is a language that allows users to access and manipulate (such as: creation, saving and destruction of) data organization.

Page 110: Object Oriented Analysis and Design using UML. L19-Design

DML (Con’t)

• The Structured Query Language (SQL) is the standard DML for relational DBMS.

• In a relational DBMS, the DML is independent from a host programming language.

Page 111: Object Oriented Analysis and Design using UML. L19-Design

DML (Con’t)

• For example, a host language such as C or COBOL would be used to write the body of the application.

• SQL statements are then typically embedded in C or COBOL applications to manipulate data.

Page 112: Object Oriented Analysis and Design using UML. L19-Design

Sharability• Data in the database often needs to be

accessed and shared by different applications.

• The database then must detect and mediate the conflicts and promote the greatest amount of sharing possible without sacrificing the integrity of data.

Page 113: Object Oriented Analysis and Design using UML. L19-Design

Transaction• A transaction is a unit of change, in which

either all changes to objects within a transaction will be applied or not at all.

• A transaction is said to commit if all changes can be successfully made to the database and to abort if all changes cannot be successfully made to the database.

Page 114: Object Oriented Analysis and Design using UML. L19-Design

Concurrency Control

• Programs will attempt to read and write the same pieces of information simultaneously and, in doing so, create a contention for data.

• The concurrency control mechanism is

thus established to

mediate these conflicts.

Page 115: Object Oriented Analysis and Design using UML. L19-Design

Concurrency Control (Con’t)

• It does so by making policies that dictate how read and write conflicts will be handled.

Page 116: Object Oriented Analysis and Design using UML. L19-Design

Concurrency Control (Con’t)

• The most conservative way is to allow a user to lock all records or objects when they are accessed and to release the locks only after a transaction commits.

Page 117: Object Oriented Analysis and Design using UML. L19-Design

Concurrency Control (Con’t)

• By distinguishing between reading the data, and writing it (which is achieved by qualifying the type of lock placed in the data-read lock or write lock) somewhat greater concurrency can be achieved.

• This policy allows many readers of a record or an objective, but only one writer.

Page 118: Object Oriented Analysis and Design using UML. L19-Design

Distributed Databases

• In distributed databases portions of the database reside on different nodes (computers) in the network.

Page 119: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Computing

• Client/server computing allows objects to be executed in different memory spaces or even different machines.

Page 120: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Computing (Con’t)

• The calling module becomes the "client" (which requests a service), and the called module becomes the "server" (which provides the service).

Page 121: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Computing (Con’t)

Client programs usually manage:

• The user-interface

• Validate data entered by the user

• Dispatch requests to server programs, and sometimes

• Execute business logic.

Page 122: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Computing (Con’t)

• The Business layer contains all of the objects that represent the business such as: – Order – Customer – Line Item – Inventory, etc.

Page 123: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Computing (Con’t)

• A server process (program) fulfills the client request by performing the task requested.

• Server programs generally receive requests from client programs, execute database retrieval and updates, manage data integrity, and dispatch responses to client requests.

Page 124: Object Oriented Analysis and Design using UML. L19-Design

• A two-tier architecture is one where a client talks directly to a server, with no intervening server.

• This type of architecture is typically used in small environments with less than 50 users.

A Two-Tier Architecture

Page 125: Object Oriented Analysis and Design using UML. L19-Design

A Two-Tier Architecture (Con’t)

SERVER

APPLICATION

CLIENTCLIENTCLIENT

LAN or WAN

APPL. APPL. APPL.

Printer

Data

Page 126: Object Oriented Analysis and Design using UML. L19-Design

A Three-Tier Architecture

• A three-tier architecture introduces another server (or an "agent") between the client and the server.

• The role of the agent is many fold.

• It can provide translation services as in adapting a legacy application on a mainframe to a client/server environment.

Page 127: Object Oriented Analysis and Design using UML. L19-Design

A Three-Tier Architecture (Con’t)

UNIX SERVER

Host (i.e. IBM 3090)

CLIENT

Sybase RDBMS

Legacy applications: DB2 RDBMS

APPLICATIONSWindows 9xACCESSLotus

Agent

Page 128: Object Oriented Analysis and Design using UML. L19-Design

Basic Characteristics of Client/Server Architectures

• 1. The client or front-end interacts with the user, and a server or back-end interacts with the shared resource.

Page 129: Object Oriented Analysis and Design using UML. L19-Design

Basic Characteristics of Client/Server Architectures

(Con’t)2. The front-end task and back-end task

have fundamentally different requirements for computing resources.

Resources such as processor speeds, memory, disk speeds and capacities, and input/output devices.

Page 130: Object Oriented Analysis and Design using UML. L19-Design

• 3. The environment is typically heterogeneous and multi-vendor.

Basic Characteristics of Client/Server Architectures (Con’t)

Page 131: Object Oriented Analysis and Design using UML. L19-Design

Basic Characteristics of Client/Server Architectures (Con’t)

• 4. Client-server systems can be scaled horizontally or vertically.

• Horizontal scaling means adding or removing client workstations with only a slight performance impact.

• Vertical scaling means migrating to a larger and faster server machine or multi servers.

Page 132: Object Oriented Analysis and Design using UML. L19-Design

Distributed Processing

• Distributed processing implies that processing will occur on more than one processor in order for a transaction to be completed.

Server 2 Server 1

Client Client Client

ApplicationFragment 1

ApplicationFragment 2

Page 133: Object Oriented Analysis and Design using UML. L19-Design

Distributed Processing (Con’t)

• For example, in processing an order from our client, the client information may process at one machine and the account information will then be processed next on a different machine.

Page 134: Object Oriented Analysis and Design using UML. L19-Design

Cooperative processing

• Cooperative processing is a form of distributed computing where two or more distinct processes are required to complete a single business transaction.

Cooperative Processing

APPLICATIONSWindows 9xACCESSLotus

APPLICATIONSWindows 9xACCESSLotus

SERVER

Page 135: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Components

I. User Interface Layer: This is one of the major components of the client/server application.

It interacts with users, screens, Windows, Window management, keyboard, and mouse handling.

Page 136: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Components (Con’t)

II. Business Processing Layer: This is a part of the application that uses the user interface data to perform business tasks.

Page 137: Object Oriented Analysis and Design using UML. L19-Design

Client/Server Components (Con’t)

III. Database Processing Layer: This is a part of the application code that manipulates data within the application.

Page 138: Object Oriented Analysis and Design using UML. L19-Design

Distributed Object Computing (DOC)

• Distributed object computing promises the most flexible client/server systems.

• It utilizes reusable software components that can roam anywhere on networks, run on different platforms, communicate with legacy applications.

Page 139: Object Oriented Analysis and Design using UML. L19-Design

DOC (Con’t)

• Currently, there are several competing DOC standards, including:– Microsoft's ActiveX/DCOM– the Object Management Group's CORBA,

and– OpenDoc.

Page 140: Object Oriented Analysis and Design using UML. L19-Design

Common Object Request Broker Architecture (CORBA)

• CORBA provides means to integrate distributed, heterogeneous business applications and data.

• The CORBA Interface Definition Language (IDL) allows developers to specify language-neutral, object-oriented interfaces for application and system components.

Page 141: Object Oriented Analysis and Design using UML. L19-Design

Object Request Brokers (ORBs)• ORBs implement a communication channel

through which applications can access object interfaces and request data and services.

Object Request Broker (ORB)

DomainObjects

NamingPersistenc

eEvents

Concurrency

Transaction

Application Objects

Page 142: Object Oriented Analysis and Design using UML. L19-Design

Microsoft's ActiveX/DCOM

• The Distributed Component Object model, Microsoft's alternative to OMG's CORBA.

• DCOM is an Internet and component strategy where ActiveX (formerly known as object linking and embedding, or OLE) plays the role of DCOM object.

Page 143: Object Oriented Analysis and Design using UML. L19-Design

Object-Oriented Database Systems

Database capabilities

DataEncapsulatio

n

Polymorphism

Object-Oriented programming

ObjectIdentity

Object&Class

Concurrenc

y

Security

Recovery

Query

Integrity

Versioning

Archive

Persistence

Inheritance

• The object-oriented database management system is a marriage of object-oriented programming and database technology to provide what we now call object-oriented databases.

Page 144: Object Oriented Analysis and Design using UML. L19-Design

Object-Oriented Database System Manifesto

• Malcolm Atkinson et al. described the necessary characteristics that a system must satisfy to be considered an object-oriented database.

• These categories can be broadly divided into object-oriented language properties and database requirements.

Page 145: Object Oriented Analysis and Design using UML. L19-Design

Manifesto (Con’t)• First, the rules that make it an object-oriented

system are as follows:– 1. The system must support complex objects. – 2. Object identity must be supported. – 3. Objects must be encapsulated. – 4. The system must support types or classes. – 5. The system must support inheritance. – 6. The system must avoid premature binding.– 7. The system must be computationally complete.

Page 146: Object Oriented Analysis and Design using UML. L19-Design

Manifesto (Con’t)

– 8. The system must be extensible.

• Second, these rules make it a DBMS:– 9. It must be persistent, able to remember an object

state. – 10. It must be able to manage very large databases. – 11. It must accept concurrent users. – 12. It must be able to recover from hardware and

software failures. – 13. Data query must be simple.

Page 147: Object Oriented Analysis and Design using UML. L19-Design

Object-Oriented Databases versus Traditional Databases

• The objects are an "active" component in an object-oriented database.

• Relational database systems do not explicitly provide inheritance of attributes and methods.

Page 148: Object Oriented Analysis and Design using UML. L19-Design

Object-Oriented Databases versus

Traditional Databases (Con’t)

• Each object has its own identity, or object-ID (as opposed to the purely value-oriented approach of traditional databases).

• Object identity allows objects to be related as well as shared within a distributed computing network.

Page 149: Object Oriented Analysis and Design using UML. L19-Design

Object-Relational Systems: The Practical World

• In practice, even though many applications increasingly are developed in an object-oriented environment, chances are good that the data those applications need to access live in a very different universe—a relational database.

Page 150: Object Oriented Analysis and Design using UML. L19-Design

Object-Relation Mapping

• For a tool to be able to define how relational data maps to and from application objects, it must have at least the following mapping capabilities:

• Table-class mapping. • Table-multiple classes mapping.• Table-inherited classes mapping.• Tables-inherited classes mapping.

Page 151: Object Oriented Analysis and Design using UML. L19-Design

Table-Class Mapping

• Each row in the table represents an object instance and each column in the table corresponds to an object attribute.

Car

costcolormakemodel

cost color make model

Car Table

Page 152: Object Oriented Analysis and Design using UML. L19-Design

Table-Multiple Classes Mapping

• The custID column provides the discriminant. If the value for custID is null, an Employee instance is created at run time; otherwise, a Customer instance is created.

Employee

nameaddressempID

name custIDaddress

Person Table

empID

Customer

nameaddress

custID

Page 153: Object Oriented Analysis and Design using UML. L19-Design

Table-Inherited Classes Mapping

Employee

namessn

name address

Person Table

ssn

HourlyEmployee

wage

SalariedEmployee

address

salary

wage salary

• Instances of SalariedEmployee can be created for any row in the Person table that has a non null value for the salary column. If salary is null, the row is represented by an HourlyEmployee instance.

Page 154: Object Oriented Analysis and Design using UML. L19-Design

Tables-Inherited Classes Mapping

name

name address

Person Table

dept

Customer

address

company

Employee

Person

name

Employee Table

ssn

name address

Customer Table

ssn

ssn

dept

company

salary

salary

• Instances of Person are mapped directly from the Person table. However, instances of Employee can be created only for the rows in the Employee table (the joins of the Employee and Person tables on the ssn key). The ssn is used both as a primary key on the Person table and as a foreign key on the Person table and a primary key on the Employee table for activating instances of

type Employee.

Page 155: Object Oriented Analysis and Design using UML. L19-Design

Keys for Instance Navigation

name

Department Table

Department

name

Employee

name

Employee Table

ssndpartment ID salary

salary

department ID

name

ssndepartment ID

• The departmentID property of Employee uses the foreign key in column Employee.departmentID. Each Employee instance has a direct reference of class Department (association) to the department object to which it belongs.

Page 156: Object Oriented Analysis and Design using UML. L19-Design

Multidatabase System

• A different approach for integrating object-oriented applications with relational data environments is multidatabase systems, or heterogeneous database systems, which facilitate the integration of heterogeneous databases and other information sources.

Page 157: Object Oriented Analysis and Design using UML. L19-Design

Federated Multidatabase Systems

• Federated multidatabase systems provide a solution to the problem of interoperating heterogeneous data systems, provide uniform access to data stored in multiple databases that involve several different data models.

Page 158: Object Oriented Analysis and Design using UML. L19-Design

MDBS (Con’t)

• A multidatabase system (MDBS) is a database system that resides on top of, say existing relational and object databases and file systems (called local database systems) and presents a single database illusion to its users.

Application

OODBMS DBMS DBMS OODBMS

Local Databases

Virtual database

Page 159: Object Oriented Analysis and Design using UML. L19-Design

Characteristics of MDBS• Automatic generation of a unified global

database schema from local databases.

• Provision of cross-database functionality (global queries, updates, and transactions) by using unified schemata.

• Integration of a heterogeneous database system with multiple databases.

Page 160: Object Oriented Analysis and Design using UML. L19-Design

Characteristics of MDBS (Con’t)

• Integration of data types other than relational data through the use of such tools as driver generators.

• Provision of a uniform but diverse set of interfaces (e.g., a SQL-style interface, browsing tools, and C++) to access and manipulate data stored in local databases.

Page 161: Object Oriented Analysis and Design using UML. L19-Design

Open Database Connectivity

• Open database connectivity (ODBC), provides a mechanism for creating a virtual DBMS.

Application programs

ODBC driver manager

Database A

Database B

Database C

Database D

Database E

Loadable ODBC driver

Driver for database A

Driver for database B

Driver for database C

Driver for Database D

Driver for database E

...

ODBCAPI

Page 162: Object Oriented Analysis and Design using UML. L19-Design

Designing Access Layer Classes

• The main idea behind creating an access layer is to create a set of classes that know how to communicate with data source, whether it be a file, relational database, mainframe, Internet, DCOM, or via ORB.

• The access classes must be able to translate any data-related requests from the business layer into the appropriate protocol for data access.

Page 163: Object Oriented Analysis and Design using UML. L19-Design

Access Layer Classes (Con’t)

• The business layer objects and view layer objects should not directly access the database. Instead, they should consult with the access layer for all

external system

connectivity.

DBMS Serveror

Legacy data andapplication

Database, ORB, Internet, etc.

View layer objects

Business Layer Objects

Access Layer Objects

Application /WebServer

ClientClientClient

Page 164: Object Oriented Analysis and Design using UML. L19-Design

Benefits of Access Layer Classes

• Access layer classes provide easy migration to emerging distributed object technology, such as CORBA and DCOM.

• These classes should be able to address the (relatively) modest needs of two-tier client/server architectures as well as the difficult demands of fine-grained, peer-to-peer distributed object architectures.

Page 165: Object Oriented Analysis and Design using UML. L19-Design

Process• The access layer design process consists of

these following activities:1. If methods will be stored in a program then

For every business class identified, determine if the class has

persistent data. else

For every business class identified, mirror the business class package.

2. Define relationships. The same rule as applies among

business class objects also applies among access classes.

Page 166: Object Oriented Analysis and Design using UML. L19-Design

Process (Con’t)

3. Simplify classes and relationships. The main goal here is to eliminate redundant or unnecessary classes or structures.

3.1. Redundant classes. If you have more than one class that provides similar services, simply select one and eliminate the other(s).

3.2. Method classes. Revisit the classes that consist of only one or two methods to see if they can be eliminated or combined with existing classes.

4. Iterate and refine.

Page 167: Object Oriented Analysis and Design using UML. L19-Design

Process of Creating Access Layer Classes

BusinessLayer

AccessLayer

Class1

Class2 Class3

Step 1: Mirror business class package

Class1DB

Class2DB Class3DB

Accesslayer

Class1DB

Class2DB Class3DB

Step 2: Define relationships

Accesslayer

Accesslayer

Class1

Class2 Class3

Class1DB

Class2DB Class3DB

Step 3: Simplify classes and relationships

Page 168: Object Oriented Analysis and Design using UML. L19-Design

Access Layer Classes (Con’t)

• The relation between a business class and its associated access class.

Class1

Class1DB

Business class

Access classfor Class1

Page 169: Object Oriented Analysis and Design using UML. L19-Design

Class 1

Class 1 DB

The Relation between a business class and its associated access class

Business class

Access class for Class 1

Page 170: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

•An access layer is to create a set of classes that know how to communicate with the data source.

• They are simply mediators between business or view classes and storage places or they communicate with other objects over a network through the ORB/DCOM.

• Creating an Access Class for the BankClient Class

• Step 1. Determine if a class has persistent data.

• Step 2. Mirror the business class package. Since the BankClient has persistent at attributes, we need to create an access class for it.

• Step 3. Define relationships.

• The BankClient class has the following attributes:• First name• Last name• Card number• Pin number• Account

Page 171: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

firstName lastName cardNumnber pinNumer cardNumnber

Bank Client

firstNamelastName

cardNumberpinNumber

account

Account

NumberBalance

bankClient

Transaction

ACCOUNT Table

cardNumber

BANK CLIENT Table

Page 172: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

• The access class must update and retrieve the BankClient attributes by translating any data-related requests from the BankClient class into the appropriate protocol for data access.

• BnakClient : : +retrieveClient (aCardNumber,aPIN): BankClientaBankDB : BankDBaBAnkDB.retrieveClient (aCardNumber, a PIN)

– The retrieveClient of the BankDB class will do the actual work of getting the

information from the database.

• BankDB : : +retrieveClient (aCardNumber, aPIN) : BankClient SELECT firstName, lastName

FROM BANKCLIENTWHERE cardNumber = acardNumber and pinNumber = aPin

• BankDB : : +updateClient (aClient: BankClient, aCardNumber: string) UPDATE BANKCLIENT

Set firstName=aClient. firstNameSet lastName=aClient. lastNameSet pinNumber=aClient.pinNumber

WHERE cardNumber = acardNumber

Page 173: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

firstName lastName cardNumnber pinNumer cardNumnber transID

Bank Client

firstNamelastName

cardNumberpinNumber

account

Account

NumberBalance

bankClient

Transaction

ACCOUNT Table

cardNumber

BANK CLIENT TableTransaction

transIDtransDatetransTimetransTypeAmount

postBalanceaccount

transID transDate transTime transType Amount postBalance

TRANSACTION Table

Page 174: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

firstName lastName cardNumnber pinNumer

Bank Client

firstNamelastName

cardNumberpinNumber

Account

Account

NumberBalance

bankClient

Transaction

ACCOUNT TableBANK CLIENT TableTransaction

transIDtransDatetransTimetransTypeAmount

postBalanceaccount

cardNumber

transID transDate transTime transType Amount postBalance

TRANSACTION Table

cardNumber sNumber cNumber transID sBalance cBalance

Checking Account

savings

Savings Account

checking

transID

Page 175: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

• SavingAccount : : -retrieveAccount () : Account

aBAnkDB.retrieveSavingsAccount (bankClient.cardNumber, number)

$

• BankDB : : +retrieveSavingsAccount (aCardNumber : string, savingNumber : string): Account SELECT sBalance, transID,

FROM AACOUNT WHERE cardNumber = acardNumber and Snumber = savingsNumber

• checkingAccount : : -retrieveAccount () : Account

bankDB. retrieveCheckingAccount (bankClient.cardNumber, number)

• savingsAccount : : -updateAccount () : Account

bankDB. updateSavingsAccount (bankClient.cardNumber, number, balance)

Page 176: Object Oriented Analysis and Design using UML. L19-Design

CASE STUDY: Designing the access layer for the ViaNet Bank ATM

• bankDB : :+updateSavingsAccount (acardPinNumber: string aNumber: string newBalance: float) UPDATE ACCOUNT

Set sBalance = newBalance WHERE cardNumber = acardNumber and sNumber = aNumber)

• checkingAccount : : -updateAccount () : Account

bankDB. updateCheckingAccount (bankClient.cardNumber, number, balance)

• bankDB : :+updateCheckingAccount (acardPinNumber: string aNumber: string newBalance: float) UPDATE ACCOUNT

Set sBalance = newBalance WHERE cardNumber = acardNumber and cNumber = aNumber)

Page 177: Object Oriented Analysis and Design using UML. L19-Design

Summary• The fundamental purpose of a DBMS is to

provide a reliable persistent data storage facility and the mechanisms for efficient, convenient data access and retrieval.

• Many modern databases are distributed databases.

Page 178: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)• Client/server computing is the logical

extension of modular programming.

• Distributed computing is a second client/server revolution, a transition to an immensely expanded client/server era.

• The object-oriented database technology is a marriage of object-oriented programming and database technology.

Page 179: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• In practice, even though many applications increasingly are developed using object-oriented programming technology, the data those applications need to access live in a relational database.

Page 180: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• The main process in relational-object integration is defining the relationships between the table structures (represented as schemata) in the relational database with classes (representing classes) in the object model.

Page 181: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• A different approach for integrating object-oriented applications with relational data environments involves multidatabase systems, or heterogeneous database systems, which facilitate the integration of heterogeneous databases and other information sources.

Page 182: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• The main idea behind an access layer is to create a set of classes that know how to reach the data source.

• Access layer classes provide easy migration to emerging distributed object technology, such as CORBA and DCOM.

Page 183: Object Oriented Analysis and Design using UML. L19-Design

View Layer:Designing Interface Objects

Page 184: Object Oriented Analysis and Design using UML. L19-Design

This Session focuses on

• Identifying View Classes

• Designing Interface Objects

• Guidelines to Graphical User Interface (GUI)

Page 185: Object Oriented Analysis and Design using UML. L19-Design

. . . The design of your software's interface, more than anything else, affects how a user interacts and therefore experiences your application.

Tandy Trower

Page 186: Object Oriented Analysis and Design using UML. L19-Design

Designing View Layer Classes

• interface objects– The only exposed objects of an application

with which users can interact– Represent the set of operations in the

business that users must perform to complete their tasks

Page 187: Object Oriented Analysis and Design using UML. L19-Design

Designing View Layer Classes

The view layer classes are responsible for two major aspects of the applications:

• Input-Responding to user interaction– User interface must be designed to translate

an action by the user

• Output-Displaying business objects

Page 188: Object Oriented Analysis and Design using UML. L19-Design

Designing View Layer Classes (Con’t)

• Design of the view layer classes are divided into the following activities:I. Macro Level UI Design Process- Identifying

View Layer Objects.II. Micro Level UI Design Activities.– Designing the view layer objects by applying design

axioms – Prototyping the view layer interface

III. Usability and User Satisfaction Testing.IV. Refine and Iterate.

Page 189: Object Oriented Analysis and Design using UML. L19-Design

Macro-Level Process – By analyzing usecases

1. For Every Class Identified1.1 Determine If the Class Interacts With

Human Actor: If yes, do next step otherwise move to next class.

1.1.1 Identify the View (Interface) Objects for The Class.

1.1.2 Define Relationships Among the View (Interface) Objects.

2. Iterate and refine.

Page 190: Object Oriented Analysis and Design using UML. L19-Design

Relationships Among Business, Access and View Classes

• In some situations the view class can become a direct aggregate of the access object, as when designing a web interface that must communicate with application/Web server through access objects.

Page 191: Object Oriented Analysis and Design using UML. L19-Design

Relationships Among Business, Access and View Classes

View objects

Business objects

Access objects

Page 192: Object Oriented Analysis and Design using UML. L19-Design

View Layer Micro Level• Better to design the view layer objects

user driven or user centered

• Process of designing view objects1. For Every Interface Object Identified in the

Macro UI Design Process.1.1 Apply Micro Level UI Design Rules and

Corollaries to Develop the UI.

2. Iterate and refine. Apply design rules and GUI guidelines to

design the UI for the interface objects

identified.

Page 193: Object Oriented Analysis and Design using UML. L19-Design

UI Design Rules

• Rule 1- Making the Interface Simple

• Rule 2- Making the Interface Transparent and Natural

• Rule 3- Allowing Users to Be in Control of the Software

Page 194: Object Oriented Analysis and Design using UML. L19-Design

UI Design Rule 1

• Making the interface simple: application of corollary 2.

• Keep It Simple.• Simplicity is different from being simplistic. • Making something simple requires a good

deal of work and code.• Every additional feature potentially affects

performance, complexity, stability, maintenance, and support costs of an application.

Page 195: Object Oriented Analysis and Design using UML. L19-Design

UI Design Rule 1 (Con’t)• A design problem is harder to fix after the

release of a product because users may adapt, or even become dependent on, a peculiarity in the design.

Page 196: Object Oriented Analysis and Design using UML. L19-Design

UI Design Rule 2

• Making the interface transparent and Natural: application of corollary 4.

• Corollary 4 implies that there should be strong mapping between the user's view of doing things and UI classes.

Page 197: Object Oriented Analysis and Design using UML. L19-Design

Making The Interface Natural

• The user interface should be intuitive so users can anticipate what to do next by applying their previous knowledge of doing tasks without a computer.

Page 198: Object Oriented Analysis and Design using UML. L19-Design

Using Metaphors

• Metaphore, relates two unrelated things by using one to denote the other

• Metaphors can assist the users to transfer their previous knowledge from their work environment to your application interface.

• For example, question mark to label a Help button.

Page 199: Object Oriented Analysis and Design using UML. L19-Design

UI Design Rule 3

• Allowing users to be in control of the software: application of corollary 1.

• Users should always feel in control of the software, rather than feeling controlled by the software.

Page 200: Object Oriented Analysis and Design using UML. L19-Design

Allowing Users Control of the Software

• Some of the ways to put users in control are:– Making the interface forgiving.– Making the interface visual.– Providing immediate feedback.– Making the interface consistent.

Page 201: Object Oriented Analysis and Design using UML. L19-Design

Making the Interface Forgiving

• Users should be able to back up or undo their previous action.

• They should be able to explore without fear of causing an irreversible mistake.

Page 202: Object Oriented Analysis and Design using UML. L19-Design

Making the Interface Visual

• You should make your interface highly visual so users can see, rather than recall, how to proceed.

• Whenever possible, provide users with a list of items from which they can choose.

Page 203: Object Oriented Analysis and Design using UML. L19-Design

Providing Immediate Feedback

• Users should never

press a key or select

an action without

receiving immediate

visual feedback,

audible feedback,

or both.

Not this sort of feedback!

Page 204: Object Oriented Analysis and Design using UML. L19-Design

Making the Interface Consistent

• User Interfaces should be consistent throughout the applications.

• For example, keeping button locations consistent make users feel in control.

Page 205: Object Oriented Analysis and Design using UML. L19-Design

Purpose of a User Interface

• Data Entry Windows: Provide access to data that users can retrieve, display, and change in the application.

• Dialog Boxes: Display status information or ask users to supply information.

• Application Windows (Main Windows): Contain an entire application that users can launch.

Page 206: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows

• You can use an existing paper form such as a printed invoice form as the starting point for your design.

Page 207: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows (Con’t)

If the printed form contains too much information to fit on a screen:

• Use main window with optional smaller Windows that users can display on demand, or

• Use a window with multiple pages.

Page 208: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows (Con’t)

• An example of a dialog box with multiple pages in the Microsoft multimedia setup.

Page 209: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows (Con’t)

• Users scan a screen in the same way they read a page of a book, from left to right, and top to bottom.

Page 210: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows (Con’t)

• Orient the controls in the dialog box in the direction people read.

• Usually left to right, top to bottom.

CancelOK

First Name: Last Name:

Address:

City:

State: Zip Code:

Page 211: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows (Con’t)

• Required information should be put toward the top and left side of the form, entering optional or seldom entered information toward the bottom.

Frequentlyenteredinformation Seldom

enteredinformation

Page 212: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Data Entry Windows (Con’t)

• Place text labels to the left of text box controls, align the height of the text with text displayed in the text box.

Label

Label

Possible locations for textLabels

Page 213: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Dialog Boxes

• If the dialog box is for an error message, use the following guidelines:

• Your error message should be positive.

• For example instead of displaying “You have typed an illegal date format,” display this message “Enter date format mm/dd/yyyy.”

Page 214: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Dialog Boxes(Con’t)

• Your error message should be constructive, brief and meaningful.

• For example, avoid messages such as“You should know better! Use the OK button”

• instead display “Press the Undo button and try again.”

Page 215: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For The Command Buttons Layout

• Arrange the command buttons either along the upper-right border of the form or dialog box or lined up across the bottom.

CancelOK

First Name: Last Name:

Address:

City:

State: Zip Code:

Help

Help

OK

Cancel

Or

Default Button

Page 216: Object Oriented Analysis and Design using UML. L19-Design

Buttons Layout (Con’t)• Positioning buttons on the left or center is

popular in Web interfaces.

Page 217: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Designing Application Windows

• A typical application window consists of a frame (or border) which defines its extent:

• title bar

• scroll bars

• menu bars,

• toolbars, and

• status bars.

Page 218: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Colors

• Use identical or similar colors to indicate related information.

• Use different colors to distinguish groups of information from each other.

• For example, checkout and in-stock tapes could appear in different colors.

Page 219: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Colors (Con’t)

• For an object background, use a contrasting but complementary color.

• For example, in an entry field, make sure that the background color contrasts with the data color.

Page 220: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Colors (Con’t)

• Use bright colors to call attention to certain elements on the screen.

• Use dim colors to make other elements less noticeable.

• For example, you might want to display the required field in a brighter color than optional fields.

Page 221: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Colors (Con’t)• Use colors consistently within each

window and among all Windows in your application.

• For example the colors for Pushbuttons should be the same throughout.

Page 222: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Colors (Con’t)

• Using too many colors can be visually distracting, and will make your application less interesting.

Page 223: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Colors (Con’t)• Allow the user to

modify the color configuration of your application.

Page 224: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Fonts

• Use commonly installed fonts, not specialized fonts that users might not have on their machines.

• Use bold for control labels so they will remain legible when the object is dimmed.

BAC

Page 225: Object Oriented Analysis and Design using UML. L19-Design

Guidelines For Using Fonts (Con’t))

• Use fonts consistently within each form and among all forms in your application.

• For example, the fonts for check box controls should be the same throughout.

• Consistency is reassuring to users, and psychologically makes users feel in control.

Page 226: Object Oriented Analysis and Design using UML. L19-Design

• Using too many font styles, sizes and colors can be visually distracting and should be avoided.

Guidelines For Using Fonts (Con’t))

Page 227: Object Oriented Analysis and Design using UML. L19-Design

Prototyping the User Interface

• Rapid prototyping encourages the incremental development approach, “grow, don’t build.”

Page 228: Object Oriented Analysis and Design using UML. L19-Design

Three General Steps

• Create the user interface objects visually.

• Link or assign the appropriate behaviors or actions to these user interface objects and their events.

• Test, debug, then add more by going back to step 1.

Page 229: Object Oriented Analysis and Design using UML. L19-Design

Three General StepsEnter title here

OKCancel

Create the forms and controlsEnter title here

OKCancelAdd actions

Enter title here

OKCancelTest the UI

Done

Create user interface controls

Associate actions to the user interface controls and their uses

Test/ debug

Page 230: Object Oriented Analysis and Design using UML. L19-Design

Example – Bank

• Classes– Account– ATMMachine– Bank– BankDB– CheckingAccount– SavingsAccount– Transaction

Page 231: Object Oriented Analysis and Design using UML. L19-Design

• Determine If the Class Interacts With Human Actor:– ATMMachine

• Usecases interact directly with actors– Bank transaction– Checking transaction history– Deposit checking – Deposit savings– Savings transaction history– Withdraw checking– Withdraw savings– Valid/invalid PIN

Page 232: Object Oriented Analysis and Design using UML. L19-Design

• Identify the View (Interface) Objects for The Class.

• View classes– AccountTransactionUI(for a bank transaction)– CheckingTransactionHistoryUI– DepositCheckingUI– DepositSavingsUI– SavingsTransactionHistoryUI– WithdrawCheckingUI– WithdrawSavingsUI– BankClientAccessUI(for validating a PIN)

Page 233: Object Oriented Analysis and Design using UML. L19-Design

• Define Relationships Among the View (Interface) Objects.

• The following interface objects display the transaction history– AccountTransactionUI– CheckingTransactionHistoryUI– SavingsTransactionHistoryUI

Page 234: Object Oriented Analysis and Design using UML. L19-Design

Relation between the view class and AccountTransactionUI and its associated business class (Account)

AccountTransactionUI

Account

Page 235: Object Oriented Analysis and Design using UML. L19-Design

Relation between the view class and BankClientAccessUI and its associated business class (BankClient)

BankClientAccessUI

BankClient

Page 236: Object Oriented Analysis and Design using UML. L19-Design

The view classes for checking and savings accounts

CheckingAccountUI

CheckingAccount

SavingsAccountUI

SavingsAccount

Page 237: Object Oriented Analysis and Design using UML. L19-Design

Micro Process

• Outcome of the macro process– BankClientAccessUI– MainUI– AccountTransactionUI– CheckingAccountUI– SavingsAccountUI

• Apply micro-level UI design rules and corollaries to develop the UI

• Iterate and refine

Page 238: Object Oriented Analysis and Design using UML. L19-Design

• Instead of using leading phrases like, "we could do this ..." or "It would be easier if

we ..."

• Choose phrases that give the user the feeling that he/she is in charge:“Do you think that if we did ... it would make it

easier for the users?”

“Do users ever complain about ...? We could add .. to make it easier.”

Make Users Feel in Charge

Page 239: Object Oriented Analysis and Design using UML. L19-Design

Summary• The main goal of UI is to display and

obtain information you need in an accessible, efficient manner.

• The design of your software's interface, more than anything else, affects how a user interacts and therefore experiences your application.

Page 240: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• UI must provide users with the information they need and clearly tell them what they need to successfully complete a task.

• A well-designed UI has visual appeal that motivates users to use your application.

• UI should use limited screen space efficiently.

Page 241: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)

• Designing View layer classes consists of the following steps:– I. Macro Level UI Design Process- Identifying View

Layer Objects– II. Micro Level UI Design Activities

• II.1 Designing the View Layer Objects by applying Design Axioms and corollaries .

• II. 2 Prototyping the View Layer Interface.

– III. Usability and User Satisfaction Testing– IV. Refine and Iterate

Page 242: Object Oriented Analysis and Design using UML. L19-Design

Summary (Con’t)• Guidelines are not a standalone tool, and

they cannot substitute for effective evaluation and iterative refinement within a design.

• However, they can provide helpful advice during the design process.

Page 243: Object Oriented Analysis and Design using UML. L19-Design

Implementation diagrams

• Component Diagram

• Deployment diagram

Page 244: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

• All model elements so far are design constructs!

• The design construct that may correspond to component is subsystem!

• “A component is a physical and replaceable part of a system that conforms to and provides the realization of set interfaces”-Grady Booch

• “An executable software module with identity and well defined interface”- UML definition

Page 245: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

• A component is a physical module of code.• Components can include both source code

libraries and runtime files.• For example, if you are using C++, each of

your .CPP and .H is a separate component.• The .EXE file you create after the code is

compiled is also a component.

Page 246: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

• Once the components are created, they are added to a Component diagram and relationships are drawn between them.

• The only type of relationship between components is dependency

Page 247: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

• Kinds of Components:

• Source code (ex: a file containing the code of a class)

• Binary object code (Ex: a class library)

• An executable application (Ex: a client or server in a client-server application)

Page 248: Object Oriented Analysis and Design using UML. L19-Design

Components vs Classes

• Similarities:

• Both realize set of interfaces

• Both participate in generalization, association relationships

• Both may have instances

• Both may be nested

• Both may be participants in Interactions

Page 249: Object Oriented Analysis and Design using UML. L19-Design

Components vs Classes(cont’d)

• Differences:

• Classes represent logical abstractions where as components represent physical things that live in the world of bits

• A component is the physical implementation of logical elements such as classes and collaborations

Page 250: Object Oriented Analysis and Design using UML. L19-Design

Components vs Classes(cont’d)

• Classes may have attributes and operations directly where as components services are usually available only through its interfaces

Page 251: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

Components and classes

fraudAgent fraudPolicypatternSearch

classes

fraudagent.dll component

Page 252: Object Oriented Analysis and Design using UML. L19-Design

Components and Interfaces

image.java component.java

ImageObserver

dependency Interfacerealization

Page 253: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

• The component icon is used to represent a software module with a well-defined interface.

• In the component specification, you specify the type of component in the Stereotype field (e.g., ActiveX, Applet, Application,DDL, and Executables)

Page 254: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram-cont’d

Page 255: Object Oriented Analysis and Design using UML. L19-Design

Component Diagram –(cont’d)

• A Component diagram is a UML diagram that displays the components in the system and the dependencies between them.

• Developers will know which code libraries exists and what the relationships are between them

• The component dependencies will let those who are responsible for compiling know in which order the components need to be compiled.

Page 256: Object Oriented Analysis and Design using UML. L19-Design

Component diagram showing compile time dependencies

stream.o<<library>> MyIO

MyApp<<executable>>

<<compile>>

<<link>>

Page 257: Object Oriented Analysis and Design using UML. L19-Design

Adding Components

• Documentation may include a description of the purpose of the component or a description of the class(es) in the component.

• Like classes, components can be packaged together to organize them.

Page 258: Object Oriented Analysis and Design using UML. L19-Design

• For example, if a logical view package called Orders contained classes called Order, OrderItem, and OrderForm, the corresponding Component view package would contain the components that hold the Order, OrderItem, and OrderForm classes.

Page 259: Object Oriented Analysis and Design using UML. L19-Design

Adding Component Details

• Stereotype: The first detail is a component stereotype. The stereotype controls which icon will be used to represent the component.

Page 260: Object Oriented Analysis and Design using UML. L19-Design

• Language: In Rose, you can assign languages on a component-by-component basis.

• Therefore, you can generate part of your model in C++, part in Java, part in Visual Basic, and so on, provided you have the Enterprise version of Rose installed.

• Classes: Before code can be generated for a class, it must be mapped to a component.

Page 261: Object Oriented Analysis and Design using UML. L19-Design

– The only type of relationship that exists between components is a component dependency.

– A component dependency suggests that one component depends on another

– A component dependency is drawn as a dashed arrow between the components

Adding Component Dependencies

Component B

Component A

Page 262: Object Oriented Analysis and Design using UML. L19-Design

• In this example, Component A depends upon Component B. In other words, there is some class in A that depends on some class in B

• These dependencies have compilation implications.

• In this example, because A depends on B, A cannot be compiled until B has been compiled.

• Someone reading this diagram will know that B should be compiled first, followed by A.

• As with package dependencies, you want to avoid circular dependencies with components.

Page 263: Object Oriented Analysis and Design using UML. L19-Design

• If A depends on B, and B depends on A, you cannot compile either until the other has been compiled.

• Thus, you have to treat the two as one large component.

• All circular dependencies should be removed before you attempt to generate code.

• The dependencies will let you know what may or may not be easily reused.

• In this example, A is difficult to reuse.• Because A depends on B, you cannot reuse A

without also reusing B.

Page 264: Object Oriented Analysis and Design using UML. L19-Design

Component diagram – cont’d

• Component diagram shows component types not instances of component

• Example: An executable file containing application MyApplication –component type. Component instances are running instances of the application;

• A:MyApplication, b:MyApplication are instances

Page 265: Object Oriented Analysis and Design using UML. L19-Design

Deployment Diagram

The deployment diagram shows:

• The physical communication links between hardware items (machines and other resources such as printers)

• The relationships between physical machines and processes: what runs where

Page 266: Object Oriented Analysis and Design using UML. L19-Design

Deployment Diagram

• Physical systems means nodes with association between them

• A node may be processor capable of running software components!

Page 267: Object Oriented Analysis and Design using UML. L19-Design

Deployment Diagram without Software

shillay:Workstationcraro:PC<<LAN>>

Page 268: Object Oriented Analysis and Design using UML. L19-Design

Deployment Diagram

• Unbroken lines between nodes represent physical connections between machines

• A link can be given a stereotype !

• Textual specification of link or node may include a figure for processor power or a bandwidth for a link

Page 269: Object Oriented Analysis and Design using UML. L19-Design

Deployment Diagram

• Previous diagram represents deployment diagram without a software

• When we are adding the software components ,we are presenting how the system is to operate at runtime

• Example: A particular running instance of an executable application

Page 270: Object Oriented Analysis and Design using UML. L19-Design

Deployment Diagram with a software

shillay:Workstation craro:PC

<<LAN>>OXO:GameEngine

P1:PlayerInterface

P2:PlayerInterface

Page 271: Object Oriented Analysis and Design using UML. L19-Design

Package Diagram

• Package is a collection of model elements

• Used normally to hide the details of model elements

• Packages can contain almost any model elements that you wish to group together