Principles of Object-Oriented Systems
Class vs Object
Abstraction
Encapsulation
Inheritance
Generalization
Specialization
Association
Aggregation
Composition
Polymorphism
Project Based Learning (A.I).pptx detail explanation
IT1206 Object Oriented Analysis and Design-L5
1. Object Oriented
Analysis and
Design L5
IT1206
IT1206 - Institute of Technology, University of Moratuwa
Sameera Gunathilaka - OOAD
1
Sameera
Gunathilaka
Lead Software
Engineer
ERP Technical
Consultant
2. Principles of
Object-
Oriented
Systems
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 2
Class vs Object
Abstraction
Encapsulation
Inheritance
Generalization
Specialization
Association
Aggregation
Composition
Polymorphism
3. Class, Object..
what's that?
A class is a blueprint for creating
an object
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka - OOAD 3
4. Class
• A class defines attributes
and behaviour
• attributes of the car
• It has common states and
behaviours
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 4
5. Object
• Instance of a class
• Create car objects with
specific details
• It has a id, state, behaviour
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 5
6. Abstraction
• What the object does
instead of how it is done
• Knowing a thing on a high
level
• You may never know how a
phone connects to another
phone when you enter a
number
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 6
7. Encapsulation
• Encapsulation is binding the
data and behaviors together
in a single unit
• Prevents user knowing
inside view( abstraction is
implemented)
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 7
8. Inheritance
(Generalization)
• organizing classes into a
hierarchy and enabling these
classes to inherit attributes and
behavior from classes above in
the hierarchy
• Inheritance describes an “IS A”
relationship
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 8
9. IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 9
12. Generalization
vs
Specialization
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 12
Specialization is just opposite to Generalization
Generalization is a bottom-up approach
Specialization is a top-down approach
In generalization, a higher entity must have some lower entities
In specialization, a higher entity may not have any lower entity
present.
Generalization helps in reducing the number of entities
Specialization is just opposite it increases the number of entities
13. Association
owners feed pets, pets please
owners
The link/actions between two
objects
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka - OOAD 13
14. Association vs Aggregation
vs Composition
1
4
• Aggregation and
composition are sub set of
Association
• Composition is a sub set of
Aggregation
IT1206 - Institute of Technology, University of Moratuwa
Sameera Gunathilaka - OOAD
15. Aggregation
a tail is a part of both dogs and
cats (also a composition)
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka - OOAD 15
16. Composition
a cat is a kind of pet (also
inheritance / generalization)
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka - OOAD 16
17. Aggregation vs Composition
IT1206 - Institute of Technology, University of Moratuwa
Sameera Gunathilaka - OOAD
17
Wheel can exist without the car File Cannot exist without the Folder
18. Polymorphism
• many different
implementations
• ability of an object to take
on many forms
• Draw() should be
implemented differently for
each shape
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka -
OOAD 18
19. Speak() method in
Animal class is
implemented
differently in each
sub class
IT1206 - Institute of Technology, University of Moratuwa Sameera Gunathilaka - OOAD 19
20. Exercise
Write at least three real world examples from each concept.
• Class vs Object
• Abstraction
• Encapsulation
• Inheritance
• Generalization
• Specialization
• Association
• Aggregation
• Composition
• Polymorphism
IT1206 - Institute of Technology, University of Moratuwa
Sameera Gunathilaka - OOAD
20
21. Thank you
IT1206 - Institute of Technology, University of Moratuwa
Sameera Gunathilaka - OOAD
21