



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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: Class, Compatability, Subtype, Operation, Behaviour, Polymorphism, Model, Advantage, Reciever, Draw
Typology: Slides
1 / 43
This page cannot be seen from the preview
Don't miss anything!




































►
A class is behaviorally compatible withanother if it supports all the operations ofthe other class
►
Such a class is called subtype
►
A class can be replaced by its subtype
Shape
colorverticesmovesetColordraw
Circle
radiusdrawcomputeArea
Line
lengthdraw
Triangle
angledrawcomputeArea
File
size…openprint…
ASCII File
… print…
PDF File
PS File
… print…
►
In OO model, polymorphism means thatdifferent objects can behave in differentways for the same message (stimulus)
►
Consequently, sender of a message doesnot need to know exact class of the receiver
Shape
Line
Circle
Triangle
draw
draw draw
draw
draw
View
►
Messages can be interpreted in differentways depending upon the receiver class
Shape
Line
Circle
Triangle
draw
draw draw
draw
draw
View
►
New classes can be added without changingthe existing model
Square
draw
Shape
Line
Circle
Triangle
draw
draw draw
draw
draw
View
An Example
►
Develop a graphic editor that can drawdifferent geometric shapes such as line,circle and triangle. User can select, move orrotate a shape. To do so, editor providesuser with a menu listing differentcommands. Individual shapes can begrouped together and can behave as asingle shape.
Eliminate irrelevant classes
►
Editor – Very broad scope
►
User – Out of system boundary
Add classes by analyzing requirements
►
Group – required to behave as a shape
“Individual shapes can be grouped together andcan behave as a single shape”
►
View – editor must have a display area
Line
Circle
Triangle
Group
Shape
View
Menu
Extract verbs connecting objects
“Individual shapes can be groupedtogether”
Group consists of lines, circles, triangles
Group can also consists of other groups
(Composition)