Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a...
-
Upload
audrey-moody -
Category
Documents
-
view
221 -
download
0
Transcript of Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a...
![Page 1: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/1.jpg)
Object Oriented System Software Engineering
![Page 2: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/2.jpg)
Object Oriented Analysis & Design - 1
Everything is a class class is a blueprint, abstract
object has identity, exists
Real world models OO attempts to model real world
![Page 3: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/3.jpg)
Class diagrams
Note - class name is singular
Class identifier
attributes
methods
TREE
Species Height Number of branches
Germinate Grow Shed leaves Die
![Page 4: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/4.jpg)
Class diagrams
Classes change iterative process
expect change
![Page 5: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/5.jpg)
Classes
Relationships between classes
Three relationships: association
aggregation
generalization/specialization (or inheritance)
![Page 6: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/6.jpg)
Association
loosest relationship
some communication between the classes
e.g. Student to Module
STUDENT MODULE
![Page 7: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/7.jpg)
Aggregation
one class is ‘part of’ another class
tighter than an association
one class ‘is part of’ another class
if you can answer ‘yes’ - probably aggregation
e.g. Course to Module
COURSE MODULE
![Page 8: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/8.jpg)
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 accountBANK ACCOUNT
CURRENT ACCOUNT
![Page 9: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/9.jpg)
Inheritance
may be several classes inheriting from one parent class
Ancestor classes are also referred to as base classes
BANK ACCOUNT
CURRENT ACCOUNT
DEPOSIT ACCOUNT
![Page 10: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/10.jpg)
Inheritance
Ancestor Classes
real power and impact of inheritance becomes clearer when
we start to add attributes and methods
first add some attributes and
methods to the class BUILDING
must remember that they
must apply to all BUILDINGs
BUILDING
WallsNumber of rooms
BuildDestroy
HOUSE
![Page 11: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/11.jpg)
Inheritance
HOUSE now inherits all the generalized attributes and
methods from BUILDING
then we can add the specialized attributes that make it
special
becomes more interesting when there is more than
one class inheriting from the parent class
![Page 12: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/12.jpg)
Inheritance
class HOUSE has the attributes
Front door
Back door
Kitchen
Roof
Garden
PLUS
Walls
Number of rooms
BUILDING
WallsNumber of rooms
BuildDestroy
HOUSE
Front doorBack doorKitchenRoofGarden
Pay mortgage
OFFICE
EntranceRest room
Pay commercial rent
FLAT
Front doorLandlordKitchen
Pay landlord
![Page 13: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/13.jpg)
Ancestral trees
class will inherit all attributes
methods
from all its ancestors
UNIVERSITY MEMBER
NameAddress
JoinLeave
STAFF
Payroll number
EmployedWorks
STUDENT
ACADEMIC
SubjectDepartment
TeachesSets examsMarks work
Administrative
![Page 14: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/14.jpg)
UML and case tools
notation used to draw the class diagrams
the Unified Modeling Language or UML
released in January 1997, quickly established itself as an
industry standard
Several case tools Rational Rose
Select Enterprise Modeler
![Page 15: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/15.jpg)
Multiplicity
can show how many of one class we can expect to
find with another
called multiplicity
e.g. car - wheelCar
Wheel
3..4
1
![Page 16: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/16.jpg)
Multiplicity
* character actually
means ‘0 or more’
a STUDENT will be
associated with zero,
one or many modules,
and a module will be
associated with zero,
one or many STUDENTs
Student
Module
*
*
![Page 17: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/17.jpg)
Multiplicities
blank not determined
0 zero
1 one
* zero, one or many
1 ..* one or many
1 .. 5 one to five
other combinations as required
2 .. 6 two to six
3 .. * three to many
![Page 18: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/18.jpg)
Relationship labels
Car
Wheel
3..4
1
a part of
Car
Wheel
3..4
1
comprises
or
![Page 19: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/19.jpg)
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
![Page 20: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/20.jpg)
Objects
class STUDENT may be
This is a declaration of what we expect every student to
have and do
Student
First nameSurnameGenderDate of birthStudent numberEye ColourNationality
EnrolSubmit assignmentSit exam
![Page 21: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/21.jpg)
Objects
An object created from this class might be
an object has identity
values
and is unique
Student1
Emma SmithFemale
15. 11. 7910012345BlueBritish
EnrolSubmit assignmentSit exam
![Page 22: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/22.jpg)
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.
When we constructed the objects above we gave the
attributes values which make each object different
from the next, even though they are all instances of
the same class
![Page 23: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/23.jpg)
Destructors
Eventually the objects will no longer be required. (Hopefully
all students will eventually complete their course and will
cease being students.)
When producing class diagrams this may not seem
important, but when the system is implemented this will
need to be considered.
When we have finished with an object it should be
destroyed using a destructor. Some languages do this for
you, others expect you to do it.
![Page 24: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/24.jpg)
Encapsulation
also referred to as data hiding
need to ensure that the values of the object are
protected, so that they cannot be interfered with, and
cannot be accidentally changed
object is encapsulated, attributes and methods should
be carefully controlled so that access to them is only
allowed in a controlled way
![Page 25: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/25.jpg)
Message Passing
class’s data or attribute values should only be
accessible through message passing
if you want the value of an attribute then ask for it and
you will be given it, but you shouldn’t have direct
access to it
![Page 26: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/26.jpg)
Encapsulation/message passing
e.g. class student
doesn’t matter how
the date is stored,
providing a recognizable date
is returned when
a message is passed asking for it
Student
Id NumberSurnameFirst NamesDate of BirthAge
Set Id NumberSet SurnameSet First NamesSet date of BirthSet Age
![Page 27: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/27.jpg)
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
![Page 28: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/28.jpg)
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
![Page 29: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/29.jpg)
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
![Page 30: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/30.jpg)
Polymorphism
Inheritance gives all attributes and methods of parents
Inheritance also allows polymorphism
poly many
morph form
many forms
![Page 31: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/31.jpg)
Polymorphism
Shape
ColourNumber of anglesDraw
Circle
radiusDraw
Rectangle
HeightLengthDraw
![Page 32: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/32.jpg)
Polymorphism
Circle RectangleAttributes: Attributes:Colour Colour (from Shape)
Number of angles Number of angles (from Shape)
Radius HeightLength
Methods: Methods:Draw Draw (from Shape)
Draw Draw
![Page 33: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/33.jpg)
Static and Dynamic Binding
Notice: each has two Draw methods
generalized Draw - shape
specialized Draw - their own specific outline
necessary to redefine the Draw method as they will need
to do something different from the ancestor class
![Page 34: Object Oriented System Software Engineering. Object Oriented Analysis & Design - 1 Everything is a class class is a blueprint, abstract object has identity,](https://reader036.fdocuments.in/reader036/viewer/2022062315/56649ebd5503460f94bc6da2/html5/thumbnails/34.jpg)
Static and Dynamic Binding
Which method will be used?
At the time of writing and compiling the program we may
not know
Procedural programming - static binding (compile time)
OO languages - dynamic binding (run-time)