Computer Notes - Abstraction

0

No comments posted yet

Comments

Slide 1

Abstraction http://ecomputernotes.com

Slide 2

Abstraction Abstraction is a way to cope with complexity. Principle of abstraction: “Capture only those details about an object that are relevant to current perspective” http://ecomputernotes.com

Slide 3

Example – Abstraction Attributes - Name - Employee ID - Student Roll No - Designation - Year of Study - Salary - CGPA - Age Ali is a PhD student and teaches BS students http://ecomputernotes.com

Slide 4

Example – Abstraction Ali is a PhD student and teaches BS students behaviour - Study - DevelopExam - GiveExam - TakeExam - PlaySports - Eat - DeliverLecture - Walk http://ecomputernotes.com

Slide 5

Example – Abstraction Attributes - Name - Employee ID - Student Roll No - Designation - Year of Study - Salary - CGPA - Age Student’s Perspective http://ecomputernotes.com

Slide 6

Example – Abstraction Student’s Perspective behaviour - Study - DevelopExam - GiveExam - TakeExam - PlaySports - Eat - DeliverLecture - Walk http://ecomputernotes.com

Slide 7

Example – Abstraction Attributes - Name - Employee ID - Student Roll No - Designation - Year of Study - Salary - CGPA - Age Teacher’s Perspective http://ecomputernotes.com

Slide 8

Example – Abstraction Teacher’s Perspective behaviour - Study - DevelopExam - GiveExam - TakeExam - PlaySports - Eat - DeliverLecture - Walk http://ecomputernotes.com

Slide 9

Example – Abstraction Ordinary Perspective A pet animal with Four Legs A Tail Two Ears Sharp Teeth Surgeon’s Perspective A being with A Skeleton Heart Kidney Stomach A cat can be viewed with different perspectives http://ecomputernotes.com

Slide 10

Example – Abstraction Driver’s View Engineer’s View http://ecomputernotes.com

Slide 11

Abstraction – Advantages Simplifies the model by hiding irrelevant details Abstraction provides the freedom to defer implementation decisions by avoiding commitment to details http://ecomputernotes.com

Slide 12

Classes In an OO model, some of the objects exhibit identical characteristics (information structure and behaviour) We say that they belong to the same class http://ecomputernotes.com

Slide 13

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 http://ecomputernotes.com

Slide 14

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 http://ecomputernotes.com

Slide 15

Graphical Representation of Classes (Class Name) (attributes) (operations) (Class Name) Normal Form Suppressed Form http://ecomputernotes.com

Slide 16

Example – Graphical Representation of Classes Circle center radius draw computeArea Normal Form Suppressed Form Circle http://ecomputernotes.com

Slide 17

Example – Graphical Representation of Classes Person name age gender eat walk Normal Form Suppressed Form Person http://ecomputernotes.com

Slide 18

Inheritance A child inherits characteristics of its parents Besides inherited characteristics, a child may have its own unique characteristics http://ecomputernotes.com

Slide 19

Inheritance in Classes If a class B inherits from class A then it contains all the characteristics (information structure and behaviour) of class A The parent class is called base class and the child class is called derived class Besides inherited characteristics, derived class may have its own unique characteristics http://ecomputernotes.com

Slide 20

Example – Inheritance Person Teacher Doctor Student http://ecomputernotes.com

Slide 21

Example – Inheritance Shape Circle Triangle Line http://ecomputernotes.com

Slide 22

Inheritance – “IS A” or “IS A KIND OF” Relationship Each derived class is a special kind of its base class http://ecomputernotes.com

Slide 23

Example – “IS A” Relationship Person name age gender eat walk Teacher designation salary teach takeExam Student program studyYear study heldExam Doctor designation salary checkUp prescribe

Slide 24

Example – “IS A” Relationship Shape color coord draw rotate setColor Circle radius draw computeArea Line length draw Triangle angle draw computeArea

Slide 25

Inheritance – Advantages Reuse Less redundancy Increased maintainability http://ecomputernotes.com

Slide 26

Reuse with Inheritance Main purpose of inheritance is reuse We can easily add new classes by inheriting from existing classes Select an existing class closer to the desired functionality Create a new class and inherit it from the selected class Add to and/or modify the inherited functionality http://ecomputernotes.com

Slide 27

Example Reuse Shape color coord draw rotate setColor Circle radius draw computeArea Line length draw Triangle angle draw computeArea

Slide 28

Example Reuse Person name age gender eat walk Teacher designation salary teach takeExam Student program studyYear study heldExam Doctor designation salary checkUp prescribe

Slide 29

Example Reuse Person name age gender eat walk Teacher designation salary teach takeExam Student program studyYear study heldExam Doctor designation salary checkUp prescribe

Summary: http://ecomputernotes.com - Computer Notes - Abstraction in Object oriented Programming what is Abstraction OOPs Explain about it in detail .explain it with example

Tags: computer notes abstraction

URL:
More by this User
Most Viewed