Beruflich Dokumente
Kultur Dokumente
Introduction to Object
Orientation: in UML flavors
CSC403
2
Objective: Introduction
to Object Orientation
Understand the basic principle of object
orientation
Understand the basic concepts and terms of
object orientation and the associated UML
notation
Appreciate the strengths of object orientation
Understand some basic UML modeling
mechanisms
3
Introduction to Object
Orientation Topics
Object Orientation
Abstraction
Encapsulation
Modularity
Hierarchy
What is Abstraction?
A model that includes most important aspects of a given
problem while ignoring less important details
Salesperson
Customer
Product
What is Encapsulation
Hide implementation from clients
Clients depend on interface
What is Modularity?
The breaking up of something complex into
manageable pieces
Order Processing
System
Order Entry
Order Fulfillment
Billing
8
What is Hierarchy?
Level of abstraction
Increasing
abstraction
Asset
Object
Class
Attributes
Operation
Interface (Polymorphism)
Components
Package
Subsystem
Relationships
10
What is an Object?
Informally, an object represents an entity,
either physical, conceptual, or software
Physical entity
Conceptual entity
Software entity
truck
Chemical Process
Linked List
11
A More Formal
Definition
An object is a concept, abstraction, or thing
with sharp boundaries and meaning for an
application
An object is something that has
Identity
State
Behavior
12
Professor Clark
Name
Joy Clark
Employee ID
567138
Date hired
Status
Tenured
13
Prof. J. Clark
Teaches algebra
Prof. J. Clark
Teaches algebra
Prof. J. Clark
Teaches algebra
15
Representing Objects
An object is represented as rectangles with
underlined names
ProfessorClark
: Professor
ProfessorClark
Object Name Only
: Professor
Class Name Only
16
Example: Objects
Intro to OO 180
World History 200
Algebra 110
English 101
Geology 110
Geology 110
Music History 200
17
What is a Class?
A class is a description of a group of
objects with common properties
(attributes), behavior (operations),
relationships, and semantics
An object is an instance of a class
18
Sample Class
Class
Properties
Course
Behavior
Name
Add a student
Location
Delete a student
Days offered
Credit hours
Determine if it is
full
Start time
End time
19
Representing Classes
A class is represented using a
compartmented rectangle (UML)
Professor
20
Class Compartments
A class is comprised of three sections
The first section contains the class name
The second section shows the structure
(attributes)
The third section shows the behavior
(operations)
Professor
empID
Name
create()
change()
save()
delete()
21
Class Compartments
(cont.)
The second and third sections may be
suppressed if they need not be visible on
the diagram
Professor
empID
Name
create()
change()
save()
delete()
Professor
empID
Name
Professor
Professor
create()
change()
save()
delete()
Professor
22
Example: Class->obj
English 101
Intro to OO 180
CourseOffering
Geology 110
23
Classes of Objects
How many class can you see?
24
Professor Mellon
25
What is Attribute?
Object
Class
Attribute
Attribute
Value
:CourseOffering
Number=110
startTime=900
endTime=1100
CourseOffering
Number
endTime
startTime
:CourseOffering
Number=104
startTime=1300
endTime=1500
26
What is Operation?
Class
CourseOffering
addStudent()
deleteStudent()
getStartTime()
Operation
getEndTime()
27
What is Polymorphism?
The ability to hide many different
implementations behind a single interface
Manufacture A
Manufacture B
Manufacture C
OO Principle:
Encapsulation
28
What is an Interface?
Interface formalize polymorphism (no state)
Interface supports plug-and-play architecture
Tube
<<interface>>
Shape
Draw
Move
Scale
Rotate
Pyramid
Cube
29
Interface Representations
Tube
Elided/Iconic
Pyramid
Representation
(lollipop)
Cube
Canonical
(Class/Stereotype)
presentation
<<interface>>
Shape
Draw
Move
Scale
Rotate
Tube
Pyramid
Cube
30
What is a Component?
A non-trivial, nearly independent, and
replaceable part of a system that fulfills a
clear function in the context of a welldefined architecture
31
What is a Component?(Cont.)
A component may be
1. A source code component
2. A run time component or
3. An executable component
Source File
<<DLL>>
Name
Component Name
<<EXE>>
Executable Name
32
Account.cpp
Report.cpp
33
<<DLL>>
Ibank
Bank
Account
34
Interfaces and
Components
Interfaces can be realized by components
Implementation Model
Source File
Component
Name
Interface
35
What is a Package?
A package is a general purpose
mechanism for organizing elements into
groups
A model element which can contain other
model elements
Uses
Package Name
What is a Subsystem?
A cross between a package (can contain
other model elements) and a class or
collection of related classes (has behavior)
Realizes one or more interfaces which
define its behavior
Subsystem
Realization
<<subsystem>>
Subsystem Name
interface
37
Subsystems and
Components
Components are the physical realization of
an abstraction in the design
Subsystems can be used to represent the
component in the design
Design Model
Implementation
Model
Component Name
<<subsystem>>
Component Name
Current Interface
Component Interface
38
Relationships
Association
Aggregation
Composition
Dependency
Generalization
Realization
39
Relationships:
Association
An association models a semantic connection
among classes
Association name and/or Role name
Association name
Professor
Class
Works for
University
Association
Role Names
Professor
University
Employee Employer
40
Relationship:
Aggregation
Whole
Student
Schedule
Aggregation
41
Relationship:
Composition
A form of aggregation with strong
ownership and coincident lifetimes
The parts cannot survive the whole/aggregate
Part
Whole
Human
Heart (organ)
Aggregation
42
43
Association: Multiplicity
Unspecified
Exactly one
Zero or more (many, unlimited)
One or more
Zero or one
Specified range
Multiple, disjoint ranges
1
0..*
*
1..*
0..1
2..4
2,4..6
44
Multiplicity
Student
0..*
Schedule
Navigation
45
Relationship: Dependency
A relationship between two model elements
where a change in one may cause a change
in the other
None-structural, using relationship
Client
Supplier
Component
Class
Package
ClientPackage
Dependency
relationship
Client
SupplierPackage
Supplier
Dependency
relationship
46
Relationship: Generalization
Generalization is an is-a-kind of
relationship
47
Account
balance
name
number
Generalization
Relationship
Withdraw()
CreateStatement()
Subclasses
Checking
Savings
Withdraw()
GetInterest()
Withdraw()
Descendents
48
Multiple Inheritance
A class can inherit from several other
classes
FlyingThing
Animal
multiple
inheritance
Airplane
Helicopter
Bird
Wolf
Horse
49
50
Superclass
(parent)
0..*
Person
owner
1
Generalization
Subclasses
size
Car
Truck
tonnage
getTax()
Trailer
51
Relationship: 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
Interface
Client
Subsystem
Interface
Interface
Elided form
Use Case
Use-Case Realization
52
Strengths of
Object Orientation
A single paradigm
Facilitates architectural and code reuse
Models more closely reflect the real world
More accurately describe corporate data and
processes
Decomposed based on natural partitioning
Easier to understand and maintain
Stability
A small change in requirements does not mean
massive changes in the system under
development
53
customer
Product
Ship via
54
Group Exercise
Lets design class diagrams for the above
problem.
Lets do it as a group exercise
The each group representative will come
out and show your design
55
seller
buyer
Item sold
Salesperson
Customer
Product
Corporate
Individual
Truck
Shipping mechanism
Vehicle
Train
56
buyer
Item sold
Salesperson
Customer
Product
Corporate
Individual
Truck
Shipping mechanism
Vehicle
Train
Airplane
57
Stereotypes
Classify and extend the UML notational
elements
Define a new model element in terms of
another model element
May be applied to all modeling
elements
Represented with name <<boundary>>
in guillemets or
as a different icon
MyBoundaryClass
MyBoundaryClass
58
Example: Stereotypes
<<boundary>>
<<boundary>>
<<trace>>
DesignClass
<<Processor>>
Processor #1
<<Processor>>
Processor #1
59
Notes
A note can be added to any UML element
Notes may be added to add more information
to the diagram
It is a dog eared rectangle
The note may be anchored to an element with
a dashed line
MaintainScheduleForm
60
Properties
A property, or specific attribute, of a UML
element
Also called tagged values
Some properties are defined by UML
Persistence
Location (e.g., client, server)
anObject: ClassA
{persistence}
{location=server}
61
constraints
Supports the addition of new rules or
modification of existing rules
Professor
Member
1..*
Department Head
1
Department
{subset}
1
62
64