Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Level Sequence Diagrams with Composition Relationships.

Similar presentations


Presentation on theme: "Object-Level Sequence Diagrams with Composition Relationships."— Presentation transcript:

1 Object-Level Sequence Diagrams with Composition Relationships

2  Key business classes  In our sequence diagram we use objects from these classes  Associations between classes  An association between classes typically indicates that the classes can “talk” to each other (depending on direction of the association)  A composition indicates that objects must go through the container object (e.g. Order) to “talk” to the component object (e.g. OrderItem)

3 An Composition is  a special kind of association  the composition of a set of parts—a whole-part relationship  a “has a” or “consists of” relationship

4  Is an object in the design which represents key aspects of a real world entity  Also called a surrogate  First create proxy for all the actors in the system, e.g. customer, guest  Then for many of the real world objects, e.g, invoice, receipt, reservation

5 Essential property  The container (Invoice) acts as a proxy for its parts (InvoiceItem)  This means the container takes on operations which are then propagated to the individual parts. (These operations don’t necessarily cause a change in the container itself.)

6 Examples of composition  An invoice has invoice items  A company has contacts  A catalogue has catalogue items

7 When we delete Company, does ContactPerson disappear? Yes! It has no meaning without Company.

8 Here adding a ContactPerson does not change the proxy (Company).

9 When we delete Invoice, does InvoiceItem disappear? Yes! It has no meaning without Invoice. To indicate a composition, the diamond is coloured black.

10 Here adding an InvoiceItem does change the proxy (Invoice). Its totals are updated.

11 When about Catalogue and CatalogueItem? If CatalogueItem belongs to only one catalogue and it is the intersection between that Catalogue and an Item then yes, it would disappear if Catalogue were deleted and we would have a composition relationship. But note the Item itself would not disappear!

12 Composition vs Association  In contrast to the association, the involved classes do not maintain an equal relationship but the container class assumes a special role for delegation of responsibility and leadership

13  Generally a 1:M relationship  The aggregate will be the 1  The parts will be the many 1…n

14  Can describe a relationship where the parts are existence-dependent on the whole.  If the whole is deleted, the individual parts will be deleted.  If an individual part is deleted, the container will survive.

15 Composition means.  The life of the parts is subordinate to the whole.  The parts are generated together with the container later.  Parts are destroyed before the whole

16  The component parts depend on the container for existence—delete the container and the components disappear (this is called a cascading delete)

17 This sequence diagram shows the proxy relationship of Catalogue to CatalogueItem

18 This sequence diagram shows an example of the cascading delete that identifies Composition.

19 Composition vs Association  Useful in modeling—an Composition shows where there is higher binding between classes which in turn makes models easier to understand  Composition helps determine implementation (e.g. arrays, etc.)  When in doubt use an association

20 Actor (office staff)System Scans OHIP card for patientSaves the OHIP information for the customer into the database Scenario: Add OHIP Information To Patient Precondition: The View Patient scenario has been executed—a Patient is displayed on the Patient Screen Note— this means the Patient object already exists! Domain Class Diagram:

21 The container object (Patient) takes responsibility for the component object (OHIPInfo); since OHIPInfo exists only within Patient, the Patient DB update will look after updating the DB with OHIP Info.


Download ppt "Object-Level Sequence Diagrams with Composition Relationships."

Similar presentations


Ads by Google