Page 53 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 53

Unit 4: Advanced Class Modelling – I




          Self Assessment                                                                       Notes

          Fill in the blanks:
          11.  The ..................... of an association is the number of roles for each link.
          12.  ..................... association is defined as an association among n classes.

          4.4 Aggregation


          Aggregation is a kind of association, between a whole, called the assembly, and its parts, called
          the components. Aggregation is often called the “a-part-of” or “parts-explosion” relationship
          and may be nested to an arbitrary number of levels. Aggregation bears the transitivity property:
          If A is part of B and B is part of C, then A is part of C.
          Aggregation is also antisymmetric: If A is part of B, then B is not part of A. Transitivity lets you
          compute the transitive closure of an assembly—that is, you can compute the components that
          directly and indirectly compose it. Transitive closure is a term from graph theory; the transitive
          closure of a node is the set of nodes that are reachable by some sequence of edges.
          Aggregation is drawn like an association with a small diamond added next to the assembly end.


                 Example: A book consists of front matter, multiple chapters, and back matter. Front
          matter, in turn, consists of a title page and a preface; back matter consists of multiple appendixes
          and an index. This is shown in figure 4.12.

                           Figure 4.12: Aggregation is a Kind of Association with
                                    Additional Semantic Properties









                                                          Appendix
          Having presented this example, we hasten to add that aggregation does not specify order.
          An assembly is a collection of components without any implied order. A book has a well-known
          and simple order of parts; the back matter follows the chapters which follow the front mater. If
          the model had to capture component order, you would have to include comments.

          An aggregation relationship is essentially a binary association, a pairing between the assembly
          class and a component class. An assembly with many kinds of components corresponds to many
          aggregations. We define each individual pairing as an aggregation so that we can specify the
          multiplicity of each component within the assembly. This definition emphasizes that aggregation
          is a special form of association. An aggregation can be qualified, have roles, and have link
          attributes just like any other association.
          Aggregation can be fixed, variable or recursive.

               A fixed aggregate has a fixed structure; the number and types of subparts are predefined.
               A variable aggregate has a finite number of levels, but the number of parts may vary.
               A recursive aggregate contains, directly or indirectly, an instance of the same kind of
               aggregate; the number of potential levels is unlimited.



                                           LOVELY PROFESSIONAL UNIVERSITY                                   47
   48   49   50   51   52   53   54   55   56   57   58