Beruflich Dokumente
Kultur Dokumente
Programming (OOP)
Classes
► Inan OO model, some of the objects exhibit
identical characteristics (information
structure and behaviour)
(Class Name)
(Class Name)
(attributes)
Suppressed
(operations)
Form
Normal Form
Major Characteristics of OOP
►Encapsulation
►Inheritance
►Polymorphism
►Abstraction
Encapsulation
► Encapsulation is a mechanism in which data
are encapsulated into an object to protect
data from illegal access or misuse.
Person
Student Doctor
Teacher
Example – Inheritance
Shape
Line Triangle
Circle
Inheritance – “IS A” or
“IS A KIND OF” Relationship
Circle Triangle
radius Line angle
draw length draw
computeArea draw computeArea
Inheritance – Advantages
► Reuse
► Less redundancy
► Increased maintainability
Polymorphism
► Ingeneral, polymorphism refers to
existence of different forms of a single
entity
draw Shape
View
draw
print File
Editor
print
draw Shape
View
draw
► Principle of abstraction:
► Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
Example – Abstraction
Ali is a PhD student and teaches BS
students
► behaviour
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
Example – Abstraction
Student’s Perspective
► Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
Example – Abstraction
Student’s Perspective
► behaviour
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
Example – Abstraction
Teacher’s Perspective
► Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
Example – Abstraction
Teacher’s Perspective
► behaviour
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
Example – Abstraction
A cat can be viewed with different
perspectives
Engineer’s View
Driver’s View
Abstraction – Advantages
► Abstraction
provides the freedom to defer
implementation decisions by avoiding
commitment to details