Object Model
Object Model
INTRODUCTION
What is an Object?
How to Describe an Object
Object classification
WHAT IS AN OBJECT?
An object represents either a real world or abstract entity
Physical:
Software:
Individual
‘objects’ are
created from
the class
design for each
Object 1 Object 2 Object 3 Object 4
actual thing
6
CLASSES
A class is a “template” that defines the methods and
variables to be a particular type of object.
Objects of a class are called instances
Class Name
Attributes
Operations
EXAMPLE UML CLASS
Car
EngineStatus
Gear
Speed
startEngine()
stopEngine() Remember that
changeGear() the class is a
template for creating
objects
CLASS ASSOCIATIONS (I)
Represent relationships between instance of classes
Person owns a car
Association
CLASS ASSOCIATION CONTN’D
Association has two possible roles
Each a direction on the association
car to person (driven_by) & person to car (drives)
A role can be labeled
You can name the role after the target class
Symbols used in multiplicity include the following
1 (exactly one)
n (where n is a single number)
* (the range 0 to infinity)
1 .. * (the range 1 to infinity)
n1 .. n2 (where n1 and n2 are single numbers forming a range)
0 .. 1 (zero or one)
MULTIPLICITY EXAMPLE
Car Person
EngineStatus Age
Gear 1 Height
Speed
1 Driver
startEngine() driveCar()
stopEngine()
changeGear()
ASSOCIATION CLASS
Allows you to add attributes, operations and other features to
associations
Student Module
1..*
studentId moduleId
Attendance 6
NEW CLASS EXAMPLE
1 1
studentModuleDetails
studentId, moduleId
attendance, marks 1..*
6 register(),marking()
NEW CLASS EXAMPLE
Student Module
studentId moduleId
1 1
studentModuleDetails
moduleId, studentId
attendance, marks 1..*
6 register(),marking()
AGGREGATION & COMPOSITION
COMPOSITE OBJECTS
Objects which contain other objects are called composite objects.
Fuel Tank
Motorcycle
Engine Wheels
Frame
COMPOSITE OBJECTS
Motorcycle
Drives
Person
Aggregation
COMPOSITION
There is a stronger variety of aggregation called
composition
The part object(s) have no meaning when the
relationship is broken.
Diagram illustration
Book Pages
Composition
INHERITANCE
GENERALISATION
Also known
as Vehicle
inheritance
Car Lorry
INHERITANCE EXAMPLE(1)
Consider these objects
Car Truck
SUPERCLASSES AND SUBCLASSES
A class defined in terms of another.
SuperClass
Subclasses
AN INHERITANCE TREE
Vehicle
Car Truck
2 axle 3 axle
INHERITANCE TREE
Vehicle
is a vehicle
Truck is a truck
3 axle
A 3 axle truck
MULTIPLE INHERITANCE
Manager Salesman
SalaryAddition() SalaryAddition()
Management’s
Bonus Salesperson’s
Sales Manager Commission