Page 33 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 33

Unit 3: Class Modelling




          You can, also show a class without its attributes or its operations, or the name of the class can  Notes
          appear by itself as shown in Figure 3.2.

                                  Figure 3.2: Alternate Class Notations

              Class                                            Class
                                              Class
              Operations                                       attributes


          The naming conventions for classes are as follow:
               Class names are simple nouns or noun phrases.

               Attribute names in a class are simple nouns or noun phrases. The first word is not capitalized,
               but subsequent words may be capital.
               Operation names are simple verbs. As with attributes, the first word is not capitalized and
               subsequent words may be capital.

          3.1.2  Objects

          The notation for an object is the same in basic form as that for a class. There are three differences
          between the notations, which are:

               Within the top section of the class box, the name of the class to which the object belongs
               appears after a colon. The object may have a name, which appears before the colon, or it
               may be anonymous, in which case nothing appears before the colon.

               The contents of the top compartment are underlined for an object.
               Each attribute defined for the given class has a specific value for each object that belongs
               to that class.

          You can see the notion of an object you can see in Figure 3.3.
                                     Figure 3.3: Notation of Object

                  Object: Class                                        :Class

               Attribute 1 = value 1                             Attribute 1 = value 1
               Attribute 2 = value 2



                 Example: If you look around you will find many examples of real world objects such as
          your books, your desk, your television, etc.




             Notes Everything that the software object knows (state) and can do (behaviour) is expressed
            by the variables and the methods within that object. In other words, all the objects share
            states and behaviour. Let us say that a software object that models your real world bicycle
            would have variables that indicated the bicycle’s current state: its speed is 20 mph, and its
            current gear is the 3rd gear, etc.







                                           LOVELY PROFESSIONAL UNIVERSITY                                   27
   28   29   30   31   32   33   34   35   36   37   38