Software design - Lecture 13. The main topics covered in this chapter include: software design components; compile time polymorphism; runtime polymorphism; behavior commonality i-e area calculation but implementation is different;...
1 Software Design Lecture : 13 Software Design Components Ø Principle Ø Criteria Ø Techniques (this lecture) Abstract Classes Ø Abstract class is a class that can not be instantiated, it exists extensively for inheritance and it must be inherited. There are scenarios in which it is useful to define classes that is not intended to instantiate; because such classes normally are used as baseclasses in inheritance hierarchies Inheritance ü It implies the functionality of data sharing between super and sub class ü All the data members and methods of super class are available for use in sub class but not viceversa ü Subclass extends the functionality of super class to use Polymorphism Ø In the context of objectoriented programming, is the ability to create a variable, a function, or an object that has more than one form Ø Polymorphism is the ability to process objects differently depending on their data types 8 Types of Polymorphism Ø Compile time Polymorphism Ø Compile time Polymorphism also known as method overloading Ø Method overloading means having two or more methods with the same name but with different Example of Compile Time Polymorphism 10 Runtime Polymorphism Ø Run time Polymorphism also known as method overriding Ø Method overriding means having two or more methods with the same name , same signature but with different implementation 11 Example of Runtime Polymorphism 12 Example of Abstract class and Inheritance ü In an objectoriented drawing application, you can draw Triangle, rectangles and other graphic objects. They have behavior commonality ie area calculation but implementation is different 13 Abstract Class Figure Triangle Area 14 Code in Eclipse ...2 Software? ?Design Components Ø Principle Ø Criteria Ø Techniques (this? ?lecture) Abstract Classes Ø Abstract class is a class that ... objects. They have behavior commonality ie area calculation but implementation is different 13 Abstract Class Figure Triangle Area 14 Code in Eclipse