Page 310 -
P. 310

chaPter 10  •  object-oriented systems analysis and design Using Uml     277

                           Student                                              Course          Figure 10.18
                    –studentNumber                                        –courseNumber         An example of an associative
                    –creditsCompleted   1..                           0..  –courseDescription   class in which a particular section
                    –gradePointAverage                                    –numberOfCredits      defines the relationship between a
                    –department                takes           has        –departmentNumber     student and a course.
                    –major                                                +addCourse( )
                    –minor                                                +changeCourse( )
                    +changeStudent( )                                     +findCourse( )
                    +findStudent( )
                    +graduateStudent( )              Section
                    +initialize( )             –studentNumber
                    +studentComplete( )        –courseNumber
                    +viewStudent( )            –year
                                               –semester
                                               –grade
                                               +addSection( )
                                               +changeGrade( )
                                               +enrollStudent( )
                                               +recordGrade( )
                                               +withdrawStudent( )



                 called Section between the classes of Student and Course. Figure 10.18 illustrates an associa-
                 tion class called Section, shown with a dotted line connected to the many-to-many relationship
                 line.
                     An object in a class may have a relationship to other objects in the same class; this is called
                 a reflexive association. An example would be a task having a precedent task or an employee
                 supervising another employee. This is shown as an association line connecting the class to itself,
                 with labels indicating the role names, such as task and precedent task.
                 WholE/Part rElationshiPs.  A whole/part relationship occurs when one class represents a
                 whole object and other classes represent parts of that object. The whole acts as a container for
                 the parts. These relationships are shown on a class diagram by a line with a diamond on one end.
                 The diamond is connected to the object that is the whole. Whole/part relationships (as well as
                 aggregation, discussed later) are shown in Figure 10.19.
                     A whole/part relationship may be an entity object that has distinct parts, such as a computer
                 system that includes the computer, printer, display, and so on, or an automobile that has an
                 engine, a brake system, a transmission, and so on. Whole/part relationships may also be used
                 to describe a user interface, in which one GUI screen contains a series of objects such as lists,
                 boxes, or radio buttons, or perhaps a header, body, and footer area. Whole/part relationships
                 have three categories: aggregation, collection, and composition.
                 Aggregation  An aggregation is often described as a “has a” relationship. Aggregation provides
                 a means of showing that the whole object is composed of the sum of its parts (other objects). In
                 the student enrollment example, the department has a course, and the course is for a department.
                 This is a weaker relationship because a department may be changed or removed and the course
                 may still exist. A computer package may not be available any longer, but the printers and other
                 components still exist. The diamond at the end of the relationship line is not filled in.

                 Collection  A collection consists of a whole and its members. This may be a voting district with
                 voters or a library with books. The voters or books may change, but the whole retains its identity.
                 This is a weak association.

                 Composition  Composition, a whole/part relationship in which the whole has a responsibility
                 for the part, is a stronger relationship, and is usually shown with a filled-in diamond. Keywords
                 for composition are one class “always contains” another class. If the whole is deleted, all parts
                 are deleted. An example would be an insurance policy with riders. If the policy is canceled, the
                 insurance riders are also canceled. In a database, the referential integrity would be set to delete
                 cascading child records. In a university there is a composition relationship between a course and
                 an assignment as well as between a course and an exam. If the course is deleted, assignments and
                 exams are deleted as well.
   305   306   307   308   309   310   311   312   313   314   315