Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Relationships Lecture Oo07 Generalization Relationships.

Similar presentations


Presentation on theme: "Class Relationships Lecture Oo07 Generalization Relationships."— Presentation transcript:

1 Class Relationships Lecture Oo07 Generalization Relationships

2 References n Ambler, S., The Object Primer, Cambridge Univ. Press, 2001, Section 5.6 n Fowler & Scott, UML Distilled Applying the Standard Object Modeling Language, AWL, 1997, Chapt 4,

3 Teaching Points n Generalization Relationships n Multiple Inheritance n Base-class resolution

4 Review n What good are different architectural views? n What view do Object Interaction Diagrams give?

5 Class Diagrams n Provide a static view of the design n The types of objects in the design and the static relationship between them n Three perspectives –Conceptual –Specification –Implementation

6 Conceptual Perspective n Concepts in the domain under study n Related to classes in the final solution but not directly n Here we are really describing the problem domain

7 Specification n A view of the software design but an abstract perspective n Looking at interfaces n Therefore we are describing types n Type and Interface go together

8 Implementation n A view which can describe the secrets of a class n The data structures may be visible in this view n Classes are being described (state and interface)

9 Generalization (Inheritance) n The “kind-of” relationship n Used to exploit the commonality of objects n The primary vehicle for “reuse” in OO n Super-class/Sub-class n Base-class/Derived-class

10 Generalization

11 What is a sub-class? n A subclass IS everything its base class is n A subclass can extend the base-class with new secrets/state n A subclass can extend the base-class with new interface/behavior n A subclass can mask/change a specific behavior of the base-class

12 Various Perspectives n Conceptual –One thing is a special kind of another thing –Everything we can say about the general thing is true of the specialized thing

13 Various Perspectives n Specification –sub-typing (interface-inheritance) –interface of the more specialized thing must contain all of the elements of the interface of the more general thing –sub-type conforms to the super-type’s interface

14 Various Perspectives n Implementation –sub-classing (implementation-inheritance) –generalization becomes inheritance as it is associated with programming languages –sub-class inherits all the methods and fields of the super-class

15 Multiple Inheritance

16 Abstract Classes n Are objects normally instantiated from every class in a system?

17 Mixin Classes

18 Ambiguity n What happens to common state/methods of the shared base- class? n It is not obvious whether base-class state/methods should be shared or be replicated n Example

19

20

21 Resolving Ambiguity n C++ mechanisms –Scope resolution operator –Virtual Inheritance

22 Teaching Points n Generalization Relationships n Multiple Inheritance n Base-class resolution


Download ppt "Class Relationships Lecture Oo07 Generalization Relationships."

Similar presentations


Ads by Google