Object Oriented System Software Engineering: Lily Sun John Byrne Peter Hoornaert K242 P.Hoornaert@staffs - Ac.uk
Object Oriented System Software Engineering: Lily Sun John Byrne Peter Hoornaert K242 P.Hoornaert@staffs - Ac.uk
Software Engineering
methods Germinate
Grow
Shed leaves
Die
Class diagrams
Classes change
iterative process
expect change
Classes
Relationships between classes
Three relationships:
association
aggregation
generalization/specialization (or inheritance)
Association
loosest relationship
some communication between the classes
e.g. Student to Module
STUDENT MODULE
Aggregation
one class is ‘part of’ another class
tighter than an association
if you can answer ‘yes’ - probably aggregation
e.g. Course to Module
COURSE MODULE
Inheritance
(Generalization/Specialization)
is ‘a kind of’ e.g. house is a kind of building
one class is the child of another parent class
the child class inherits all the attributes and methods
of the parent
e.g bank account BANK ACCOUNT
CURRENT
ACCOUNT
Inheritance
may be several classes inheriting from one parent class
BANK ACCOUNT
CURRENT DEPOSIT
ACCOUNT ACCOUNT
Walls
Number of rooms
first add some attributes and
Build
methods to the class BUILDING Destroy
Kitchen Build
Destroy
Roof
Garden
PLUS
HOUSE FLAT OFFICE
Walls
Number of rooms Front door Front door Entrance
Back door Landlord Rest room
Kitchen Kitchen
Roof
Garden Pay landlord Pay commercial rent
Pay mortgage
UNIVERSITY
MEMBER
Name
Join
Leave
ACADEMIC Administrative
Subject
Department
Teaches
Sets exams
Marks work
UML and case tools
3..4
Wheel
Multiplicity
* character actually
Student
means ‘0 or more’
a STUDENT will be *
associated with zero,
one or many modules,
and a module will be *
Car Car
1 1
or
a part of comprises
3..4 3..4
Wheel Wheel
Objects
A class can be thought of as a recipe, a description or
declaration of something which we will create
We can create
an individual student
an instance or instantiation of the class
give it identity, and this is an object
Objects
Student
class STUDENT may be
First name
Surname
Gender
Date of birth
Student number
Eye Colour
Nationality
Enrol
Submit assignment
Sit exam
identity Emma
Smith
values Female
and is unique
.
15 11. 79
10012345
Blue
British
Enrol
Submit assignment
Sit exam
Constructors
We can also say that we have constructed each object.
This is an important concept when we come to
implement the design in a programming language.
Set Id Number
is returned when Set Surname
Set First Names
a message is passed asking for it Set date of Birth
Set Age
Hidden methods
Method not accessible outside class
e.g. getDoB in numeric format
getDoB in string format
don’t know how DoB is stored
don’t care providing we get DoB in requested format
method to produce it is not visible/accessible
Cohesion
consequence of encapsulation is that classes that are
self contained
attributes are not readily accessible to anything outside
the class unless a method to give access is provided
cannot make changes to anything inside the class
unless we give permission
cohesion is HIGH
Coupling
one class has a high dependency on another class
a change in one requires a change in the other
this is high coupling
OO wants LOW coupling
Polymorphism
Inheritance gives all attributes and methods of parents
Inheritance also allows polymorphism
poly many
morph form
many forms
Polymorphism
Shape
Colour
Number of angles
Draw
Circle Rectangle
radius Height
Draw Length
Draw
Polymorphism
Circle Rectangle
Attributes: Attributes:
Colour Colour (from Shape)
Number of angles Number of angles (from Shape)
Radius Height
Length
Methods: Methods:
Draw Draw (from Shape)
Draw Draw
Static and Dynamic Binding
Notice: each has two Draw methods