OOAD With Examples
OOAD With Examples
Improves Resiliency
Modularity
The breaking up of something complex
into manageable pieces Order
Entry
Order Processing
System Order
Fulfillment
Billing
Manages Complexity
Hierarchy Asset
Increasing
abstraction
Levels of abstraction
◦ Conceptual entity
Chemical Process
Linked List
◦ Software entity
Representing Objects
An object is represented as rectangles
with underlined names
: Professor
a + b = 10
ProfessorClark
Class Name Only
Professor Clark
ProfessorClark :
Professor Object Name Only
a + b = 10
Professor
Professor Clark
Class Compartments
A class is comprised of three sections
◦ The first section contains the class name
◦ The second section shows the structure
(attributes or variables)
◦ The third section shows the behavior
(operations)
Class Name Professor
name
Attributes empID
Operations create( )
save( )
delete( )
change( )
The Relationship Between Classes
and Objects
A class is an abstract definition of an
object
◦ It defines the structure and behavior of each
object in the class
◦ ItObjects
serves as a template for creating objects
Class
Professor Jones
Attribute
Object
Class
CourseOffering
Class
addStudent
deleteStudent
getStartTime
Operation getEndTime
Polymorphism
The ability to hide many different
implementations behind a single interface
Manufacturer B
Manufacturer A Manufacturer C
OO Principle:
Encapsulation
Interface
Interfaces formalize polymorphism
Interfaces support “plug-and-play”
architectures Tube
<<interface>>
Shape
Pyramid
Draw
Move
Scale
Rotate Cube
OO Principle:
Package Name Modularity
Uses
◦ Organize the model under development
◦ A unit of configuration management
Relationships
Association
◦ Aggregation
◦ Composition
Dependency
Generalization
Realization
Relationships: Association
Models a semantic connection among
classes
Association Name
Association
Role Names
Class University
Professor
Employee Employer
Relationships: Aggregation
A special form of association that models
a whole-part relationship between an
Whole aggregate (the whole) and its parts Part
Student Schedule
Aggregation
Relationships: Composition
A form of aggregation with strong
ownership and coincident lifetimes
Whole ◦ The parts cannot survive the whole/aggregate
Part
Student Schedule
Aggregation
Association: Multiplicity and
Navigation
Multiplicity defines how many objects
participate in a relationships
◦ The number of instances of one class related to
ONE instance of the other class
◦ Specified for each end of the association
Associations and aggregations are bi-
directional by default, but it is often desirable
to restrict navigation to one direction
◦ If navigation is restricted, an arrowhead is added
to indicate the direction of the navigation
Association: Multiplicity
Unspecified 1
Exactly one 0..*
Zero or more (many, unlimited)
*
1..*
Multiplicity
Navigation
Relationships: Dependency
A relationship between two model
elements where a change in one may
cause a change in the other
Class
Non-structural, “using”
Client Supplier relationship
Component
ClientPackage SupplierPackage
Dependency
relationship
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
Example: Single Inheritance
One class Ancestor
inherits from another
Account
balance
name
Superclass number
(parent) Withdraw()
CreateStatement()
Generalization
Relationship
Checking Savings
Descendents
Example: Multiple Inheritance
A class can inherit from several other
classes
FlyingThing Animal
multiple
inheritance