Relationships in OOPS…

A RELATIONSHIP is what a class or an object knows about another class or object. 
Example : Generalisation, Association, Aggregation and Composition
RELATIONSHIPS

  • Class

    • Generalization

  • Objects

    • Association
    • Aggregation
    • Compostition

UML Notations: RELATIONS2    

 Generalization (Class-to-Class) (superclass – subclass; supertype – subtype) 

  •      A Generalization follows a “is a” or “is a kind of” heuristic from a specialization class to the generalization class. (e.g., student “is a” person, video “is a kind of” inventory).

  •      Common attributes, operations and relationships are located in the generalization class and are inherited by the specialization classes

  •    Unique attributes, operations and relationships are located in the specialization classes. 

UML Generalisation

 

 

      UML Generalisation2

 

Associations 

  •  Relationships between instances (objects) of classes

  •       In association, Objects exists independently.

  •       Conceptual:associations can have two roles (bi-directional)

  •                   source –> target,

  •                    target –> source

UML Notation.. Association

      UML Notations: RELATIONS
 

Aggregation

  •       is a specialized form of ASSOCIATION in which a whole is related to its part(s).

  •        is known as a “part of” or containment relationship and follows the “has a” heuristic

  •       three ways to think about aggregations:

  •        whole-parts

  •        container-contents

  •        group-members

 Composition 

  •       is a stronger version of AGGREGATION

  •        the “part(s)” may belong to only ONE whole

  •        the part(s) are usually expected to “live” and “die” with the whole (“cascading delete”)

       UML_Aggregation and Composition

Continue ReadingRelationships in OOPS…