Software design - Lecture 19. The main topics covered in this chapter include: relationships between classes; composition – started discussion; composition – container and contained classes; windows operating systems; generalization or “IS-A” relationship;...
1 Software Design Lecture : 19 Relationships between Classes Ø Association –Discussed in Previous Lecture Ø Aggregation Discussed in previous Lecture Ø Composition – Started discussion Ø Inheritance Composition – Container and Contained classes Ø It’s a strong association. Ø It contain Objects that live and die together Ø The composition aggregation relationship is just another form of the aggregation relationship, but Composition Continues Ø Another important feature of composition aggregation is that the part class can only be related to one instance of the parent class Ø It is represented by a filled diamond shape from child to parent class with association Example of Composition Example of Composition Example Windows Operating Systems 10 Aggregation Vs Composition 11 Generalization or “ISA” relationship Ø It shows a relationship between super / sub class Ø Sub class inherit public and protected elements of super class Ø Sub class may override the behaviour of super 12 Generalization / Specialization Ø Common data elements and methods are put together in super class (Generalization) and specific data elements are put together in sub classes (Specialization) 13 Conceptual Generalization 14 Generalization Example Role attributes operations Staff Faculty Student Visitor attributes attributes attributes attributes operations operations operations operations 15 Example 16 17 Poor Generalization Example (violates the “is a” or “is a kind of” heuristic) Person attributes operations Leg Head attributes attributes attributes operations operations operations Arm 18 ...2 Relationships between Classes Ø Association –Discussed in Previous ? ?Lecture Ø Aggregation Discussed in previous? ?Lecture Ø Composition – Started discussion Ø Inheritance Composition – Container and Contained classes