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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
āŗ
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
ā¦ print
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)