Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

Main topics in this course are object-orientation, objects and classes, overloading, inheritance, polymorphism, generic programming, exception handling, introduction to design patterns. This lecture includes: Object, Oriented, Programming, Abstraction, Principle, Behaviour, Class, Inheritence, Line, Shape, Circle

Typology: Slides

2011/2012

Uploaded on 08/08/2012

anchita
anchita 🇮🇳

4.4

(7)

115 documents

1 / 29

Toggle sidebar

Related documents


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 ►Attributes- Name^

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

Ali is a PhD student and teaches BSstudents

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^ Student’s Perspective ►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

Teacher’s Perspective

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

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

Example – Abstraction ►Ordinary PerspectiveA pet animal with  Four Legs  A Tail  Two Ears  Sharp Teeth

►Surgeon’s PerspectiveA being with^ ^ A Skeleton^ ^ Heart^ ^ Kidney^ ^ Stomach

A cat can be viewed with differentperspectives

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

Classes

►In an OO model, some of the objects exhibitidentical characteristics (informationstructure and behaviour) ►We say that they belong to the same class

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

Graphical Representation of Classes^ (Class Name)(attributes)(operations)

(Class Name)

Normal Form

SuppressedForm

Example – Graphical Representation

of Classes Circle

centerradiusdrawcomputeAreaNormal Form

CircleSuppressedForm

Example – Graphical Representation

of Classes Person nameagegendereatwalk

Normal Form

Person SuppressedForm

Inheritance

►A child inherits characteristics of its parents ►Besides inherited characteristics, a childmay have its own unique characteristics

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

Example – Inheritance^ Shape

Circle

Triangle

Line

Inheritance – “IS A” or“IS A KIND OF” Relationship ►Each derived class is a special kind of itsbase class

Example – “IS A” Relationship

Person nameagegendereatwalk Teacherdesignationsalaryteach StudentprogramstudyYearstudy

DoctordesignationsalarycheckUp

Example – “IS A” Relationship

Shape colorcoorddrawrotatesetColor Circleradiusdraw

Linelength

Triangleangledraw

Inheritance – Advantages ►Reuse ►Less redundancy ►Increased maintainability