Docsity

Abstraction-Object Oriented Programming-Lecture Slides, Slides of Object Oriented Programming

Partial preview of the text

Download Abstraction-Object Oriented Programming-Lecture Slides and more Slides Object Oriented Programming in PDF only on Docsity!

Object-Oriented Programming

(OOP)Lecture No. 3

Abstraction

►Abstraction is a way to cope withcomplexity. ►Principle of abstraction:“Capture only those details about an objectthat are relevant to current perspective”

Example – Abstraction Ali is a PhD student and teaches BSstudents ►behaviour- Study^

  • DevelopExam
    • GiveExam^
    • TakeExam
      • PlaySports^
      • Eat
        • DeliverLecture
        • Walk

Example – Abstraction ►Attributes- Name^

  • Employee ID
    • Student Roll No
    • Designation
      • Year of Study
      • Salary
        • CGPA^
        • Age

Student’s Perspective

Example – Abstraction ►Attributes- Name^

  • Employee ID
    • Student Roll No
    • Designation
      • Year of Study
      • Salary
        • CGPA^
        • Age

Teacher’s Perspective

Example – Abstraction^ Teacher’s Perspective ►behaviour- Study^

  • DevelopExam
    • GiveExam^
    • TakeExam
      • PlaySports^
      • Eat
        • DeliverLecture
        • Walk

Example – Abstraction Driver’s View

Engineer’s View

Abstraction – Advantages ►Simplifies the model by hiding irrelevantdetails ►Abstraction provides the freedom to deferimplementation decisions by avoidingcommitment to details

Example – Class

►Ali studies mathematics ►Anam studies physics ►Sohail studies chemistry ►Each one is a Student ►We say these objects are

instances of the

Student class

Example – Class

►Ahsan teaches mathematics ►Aamir teaches computer science ►Atif teaches physics ►Each one is a teacher ►We say these objects are

instances of the

Teacher class

Example – Graphical Representation

of Classes Circle

centerradiusdrawcomputeAreaNormal Form

CircleSuppressedForm

Example – Graphical Representation

of Classes Person nameagegendereatwalk

Normal Form

Person SuppressedForm

Inheritance in Classes ►If a class B inherits from class A then itcontains all the characteristics (informationstructure and behaviour) of class A ►The parent class is called

base class and the

child class is called

derived class

►Besides inherited characteristics, derivedclass may have its own uniquecharacteristics

Example – Inheritance^ Person Teacher

Doctor

Student