1 / 22

Class Relationships

Class Relationships. Lecture Oo07 Generalization Relationships. References. Ambler, S., The Object Primer , Cambridge Univ. Press, 2001, Section 5.6 Fowler & Scott, UML Distilled Applying the Standard Object Modeling Language, AWL, 1997, Chapt 4, . Teaching Points.

ilori
Download Presentation

Class Relationships

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class Relationships Lecture Oo07 Generalization Relationships

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

  3. Teaching Points • Generalization Relationships • Multiple Inheritance • Base-class resolution

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

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

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

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

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

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

  10. Generalization

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

  12. Various Perspectives • 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 • 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 • 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 • Are objects normally instantiated from every class in a system?

  17. Mixin Classes

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

  19. Resolving Ambiguity C++ mechanisms Scope resolution operator Virtual Inheritance

  20. Teaching Points • Generalization Relationships • Multiple Inheritance • Base-class resolution

More Related