Object Oriented Analysis and Design Using The UML: Nabgha Hashmi Faculty of Computer Science University of Gujrat

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Object Oriented Analysis and Design

Using the UML

Nabgha Hashmi
Faculty of Computer Science
University of Gujrat

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 1
Basic Concepts of Object Orientation
 Object
 Class
 Attribute
 Operation
 Interface (Polymorphism)
 Relationships

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 2
Relationships
1. Association
i. Aggregation
ii. Composition
2. Dependency
3. Generalization
4. Realization

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 3
1. Association

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 4
Relationships: Association
 Models a semantic connection among classes

Association Name

Professor Works for University

Association
Role Names

Class University
Professor
Employee Employer

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 5
Association: Multiplicity
 Unspecified
 Exactly one 1
 Zero or more (many, unlimited) 0..*
*
 One or more 1..*

 Zero or one 0..1

 Specified range 2..4

 Multiple, disjoint ranges 2, 4..6

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 6
1.1. Aggregation

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 7
Relationships: Aggregation

 A special form of association that models a whole-part


relationship between an aggregate (the whole) and its
parts
Whole Part

Student Schedule

Aggregation

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 8
1.2. Composition

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 9
Relationships: Composition
 A form of aggregation with strong
ownership and coincident lifetimes
 The parts cannot survive the whole/aggregate
Whole Part

Student Schedule

Aggregation

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 10
UML Notations

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 11
Difference......

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 12
What If You are Not Sure What Type of Relationship to Use?

 Do not get too confuse if you are unable to decide whether a particular
whole-part relationship is best described as an aggregation or
composition because the distinction is helpful, it is not critical.

 If you are not even sure whether the relationship is best


described as Composition or Aggregation, then model it as an
Association.

 In fact, there is nothing wrong with modelling all whole-part


relationships as simple Associations.

 it will make no difference to the resulting solution.

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 13
2.Dependency

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 14
Relationships: Dependency
 A relationship between two model elements
where a change in one may cause a
change in the other
 Non-structural, “using” relationship
Client Supplier Component
Class

Package Client Supplier


Dependency
relationship

ClientPackage SupplierPackage
Dependency
relationship
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright  1998-1999 Rational Software, all rights reserved 15
3. Generalization

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 16
Relationships: Generalization
 A relationship among classes where one
class shares the structure and/or behavior
of one or more classes
 Defines a hierarchy of abstractions in which
a subclass inherits from one or more
superclasses
 Single inheritance
 Multiple inheritance
 Generalization is an “is-a-kind of”
relationship

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 17
Example: Single Inheritance
 One class inherits from another
Ancestor

Account
balance
name
Superclass number
(parent) Withdraw()
CreateStatement()
Generalization
Relationship

Checking Savings

Subclasses Withdraw() GetInterest()


Withdraw()

Descendents
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright  1998-1999 Rational Software, all rights reserved 18
Example: Multiple Inheritance
 A class can inherit from several other
classes
FlyingThing Animal

multiple
inheritance

Airplane Helicopter Bird Wolf Horse

Use multiple inheritance only when needed, and


always with caution !
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright  1998-1999 Rational Software, all rights reserved 19
4. Realization

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 20
Realization

 In UML modelling, a realization relationship is a


relationship between two model elements, in which one
model element (the client) realizes (implements or
executes) the behavior that the other model element
(the supplier) specifies.

 Realizations can only be shown on class or component


diagrams.

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 21
Relationships: Realization
 One classifier serves as the contract that
the other classifier agrees to carry out
 Found between:
 Interfaces and the classifiers that realize them
Class Component
Subsystem
Interface Interface
Interface
Elided form
 Use cases and the collaborations that realize
them
Canonical form

Use Case Use-Case Realization


OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright  1998-1999 Rational Software, all rights reserved 22
UML Tools

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 23
UML Tools
 Rational Rose is the “real world” standard; full round-trip code
generation

 Together (from Borland) is a lot like Rational Rose

 ArgoUML looks interesting (and is open source)

 BlueJ, displays simple UML diagrams

 Drawing programs with UML support

 Visio is a Microsoft tool

 Dia is a freeware clone of Visio

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 24
Tool Links

 Rational Rose

 http://www-3.ibm.com/software/awdtools/developer/rosexde/

 Together

 http://www.borland.com/together/

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 25
Tool Links
 ArgoUML

 http://argouml.tigris.org

 Visio

 http://msdn.microsoft.com/office/understanding/visio/

 Dia

 http://www.lysator.liu.se/~alla/dia

OOAD Using the UML - Introduction to Object Orientation, v 4.2


Copyright  1998-1999 Rational Software, all rights reserved 26

You might also like