From:
ecomputernotes
Views: 28
Comments: 0
http://ecomputernotes.com - Computer Notes - Hierarchy of Inheritance in Object oriented Programming what is Hierarchy of Inheritance Explain about it in detail .explain it with example
From:
ecomputernotes
Views: 16
Comments: 0
http://ecomputernotes.com - Computer Notes - Inheritance in Class in Object oriented Programming Explain about it in detail .explain it with example.How OOps work
From:
anon-389007
Views: 222
Comments: 0
Computational Aspects of Algebraic Curves (Lecture Notes Series on Computing) ,romantic ebooks online, top ten library in the world, library and the woodlands texas, items needed in a library
From:
anon-391955
Views: 300
Comments: 0
Natural language communication with computers (Lecture notes in computer science) ,libraries cockeysville, flowers in the attic ebook, the library store tremont il, polk county florida library system
Slide 1: Inheritance
http://ecomputernotes.com
Slide 2: Recap – Inheritance
class inherits all the characteristics of the base class
►Derived
inherited characteristics, derived class may have its own unique characteristics
►Besides ►Major
benefit of inheritance is reuse
http://ecomputernotes.com
Slide 3: Concepts Related with Inheritance
►Generalization ►Subtyping
(extension) (restriction)
►Specialization
http://ecomputernotes.com
Slide 4: Generalization
OO models, some classes may have common characteristics
►In
extract these features into a new class and inherit original classes from this new class
►We ►This
concept is known as Generalization
http://ecomputernotes.com
Slide 5: Example – Generalization
Line
color vertices length move setColor getLength color vertices radius move setColor computeArea
Circle
Triangle
color vertices angle move setColor computeArea
http://ecomputernotes.com
Slide 6: Example – Generalization
Shape
color vertices move setColor
Circle
radius computeArea
Triangle Line
length getLength http://ecomputernotes.com angle computeArea
Slide 7: Example – Generalization
Student
name age gender program studyYear study heldExam eat walk
Teacher
name age gender designation salary teach takeExam eat walk http://ecomputernotes.com
Doctor
name age gender designation salary checkUp prescribe eat walk
Slide 8: Example – Generalization
name age gender eat walk
Person
Student
program studyYear study heldExam
Teacher
designation salary teach takeExam
Doctor
designation salary checkUp prescribe
Slide 9: Sub-typing & Specialization
want to add a new class to an existing model
►We
an existing class that already implements some of the desired state and behaviour
►Find
the new class from this class and add unique behaviour to the new class
►Inherit
http://ecomputernotes.com
Slide 10: Sub-typing (Extension)
►Sub-typing
means that derived class is behaviourally compatible with the base class
compatible means that base class can be replaced by the derived class
►Behaviourally
http://ecomputernotes.com
Slide 11: Person
name age gender eats walks
Example – Sub-typing (Extension)
Student
program studyYear study takeExam
Slide 12: Shape
color vertices setColor move
Example – Sub-typing (Extension)
Circle
radius computeCF computeArea
Slide 13: Specialization (Restriction)
►Specialization
means that derived class is behaviourally incompatible with the base class
incompatible means that base class can’t always be replaced by the derived class
►Behaviourally
http://ecomputernotes.com
Slide 14: Example – Specialization (Restriction)
Person
age : [0..100] … setAge( a ) …
age = a
Adult
age : [18..100] … setAge( a ) …
If age < 18 then error else age = a
Slide 15: Example – Specialization (Restriction)
IntegerSet
… add( elem ) … add element to the set
NaturalSet
… add( elem ) …
If elem < 1 then error else add element to the set
Slide 16: Overriding
class may need to override the default behaviour provided by its base class
►A ►Reasons
for overriding
Provide behaviour specific to a derived class Extend the default behaviour Restrict the default behaviour Improve performance
http://ecomputernotes.com
Slide 17: Example – Specific Behaviour
Shape
color vertices draw move setColor
Circle
radius draw computeArea
Triangle Line
length draw angle draw computeArea
Slide 18: Example – Extension
Window
width height open close draw
DialogBox
controls enable draw
1- Invoke Window’s draw 2- draw the dialog box
Slide 19: Example – Restriction
IntegerSet
… add( elem ) … Add element to the set
NaturalSet
… add( elem ) …
If elem < 1 then give error else Add element to the set
http://ecomputernotes.com
Slide 20: Example – Improve Performance
Shape
►
Class Circle overrides rotate operation of class Shape with a Null operation.
color coord draw rotate setColor
Circle
radius draw rotate
Slide 21: Abstract Classes
abstract class implements an abstract concept ►Main purpose is to be inherited by other classes ►Can’t be instantiated ►Promotes reuse
►An
http://ecomputernotes.com
Slide 22: Example – Abstract Classes
Person
name age gender eat walk
Student
►Here,
Teacher
Doctor
Person is an abstract class
Slide 23: Example – Abstract Classes
Vehicle
color model accelerate applyBrakes
Car
Truck Bus
►Here,
Vehicle is an abstract class
Slide 24: Concrete Classes
►A
concrete class implements a concrete concept purpose is to be instantiated
►Main
implementation details specific to the domain context
►Provides
http://ecomputernotes.com
Slide 25: Example – Concrete Classes
Person
Student
program studyYear study heldExam
Teacher
Doctor
Student, Teacher and Doctor are concrete classes
►Here,
Slide 26: Example – Concrete Classes
Vehicle Car Truck
capacity load unload
Bus
• Here, Car, Bus and Truck are concrete classes