class relationships
DESCRIPTION
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. - PowerPoint PPT PresentationTRANSCRIPT
Class Relationships
Lecture Oo07Generalization 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
Generalization Relationships Multiple Inheritance Base-class resolution
Review
What good are different architectural views?
What view do Object Interaction Diagrams give?
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
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
Specification
A view of the software design but an abstract perspective
Looking at interfaces Therefore we are describing types Type and Interface go together
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)
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
GeneralizationUser
loginNamePassword
ClerknormalData
AdministratorspecialData
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
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
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
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
Multiple Inheritance
User
AdministratorClerk
Manager
Abstract Classes
Are objects normally instantiated from every class in a system?
UserloginNamePassword
AdministratorspecialData
ClerknormalData
Manager
Mixin Classes
BulidingComponent
WallFloorRoof
Structural
Ornamental
Wood
ReenforcedConcreate
SteelPartition
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
PersonnelRecordnameSIN
Addressstreetcity
TelephoneListingphoneNumber
EmployeeRecord
UserloginNamePassword
AdministratorspecialData
ClerknormalData
Manager
Resolving Ambiguity
C++ mechanisms– Scope resolution operator– Virtual Inheritance
Teaching Points
Generalization Relationships Multiple Inheritance Base-class resolution