Page 311 -
P. 311

278     Part 3  •  the analysis Process

              Figure 10.19                                Student                          Campus Organization
              An example of whole/part and          –studentNumber                       –organizationNumber
              aggregation relationships.            –creditsCompleted                    –organizationName
                                                    –gradePointAverage                   –organizationType
                                                    –department                          –president
                                                    –major                               –treasurer
                                                    –minor                               –secretary
                                                    +changeStudent( )                    –accountBalance
                                                    +findStudent( )                       –numberOfMembers
                                                    +graduateStudent( )                  +change( )
                                                    +initialize( )                       +changeOfficers( )
                                                    +studentComplete( )                  +new( )
                                                    +viewStudent( )





                                                                                           Fund Raising Activity
                                                                                         –activityNumber
                                                                                         –activityDescription
                                                                                         –activityType
                                                                                         –amountSpent
                                                                                         –amountReceived
                                                                                         –dateCompleted
                                                                                         +change( )
                                                                                         +new( )
                                                                                         +recordAmount( )





                                         Generalization/Specialization (Gen/Spec) Diagrams
                                         A generalization/specialization (gen/spec) diagram may be considered to be an enhanced class
                                         diagram. Sometimes it is necessary to separate the generalizations from the specific instances.
                                         As we mentioned at the beginning of this chapter, a koala bear is part of a class of marsupials,
                                         which is part of a class of animals. Sometimes we need to distinguish whether a koala bear is an
                                         animal or a koala bear is a type of animal. Furthermore, a koala bear can be a stuffed toy animal.
                                         We often need to clarify these subtleties.
                                         GEnEralization.  A generalization describes a relationship between a general kind of thing
                                         and a more specific kind of thing. This type of relationship is often described as an “is a”
                                         relationship. For example, a car is a vehicle and a truck is a vehicle. In this case, vehicle is the
                                         general thing, whereas car and truck are the more specific things. Generalization relationships
                                         are used for modeling class inheritance and specialization. A general class is sometimes called
                                         a superclass, base class, or parent class; a specialized class is called a subclass, derived class,
                                         or child class.

                                         inhEritanCE.  Several classes may have the same attributes and/or methods. When this occurs,
                                         a general class is created, containing the common attributes and methods. The specialized class
                                         inherits or receives the attributes and methods of the general class. In addition, the specialized
                                         class has attributes and methods that are unique and only defined in the specialized class. Creating
                                         generalized classes and allowing the specialized class to inherit the attributes and methods helps to
                                         foster reuse because the code is used many times. It also helps to maintain existing program code.
                                         This allows the analyst to define attributes and methods once but use them many times, in each
                                         inherited class.
                                             One of the special features of the object-oriented approach is the creation and maintenance
                                         of large class libraries that are available in multiple languages. So, for instance, a programmer
                                         using Java, .NET, or C# will have access to a huge number of classes that have already been
                                         developed.

                                         PolymorPhism.  Polymorphism (meaning “many forms”), or method overriding (not the same
                                         as method overloading), is the capability of an object-oriented program to have several versions
   306   307   308   309   310   311   312   313   314   315   316