Page 287 -
P. 287

254     Part 3  •  the analysis Process

                                         Object-Oriented Concepts
                                         Object-oriented programming differs from traditional procedural programming by examining
                                         the objects that are part of a system. Each object is a computer representation of some actual
                                         thing or event. General descriptions of the key object-oriented concepts of objects, classes, and
                                         inheritance are presented in this section, and further details on other UML concepts are intro-
                                         duced later in this chapter.

                                         Objects
                                         Objects are persons, places, or things that are relevant to the system we are analyzing. Object-
                                         oriented systems describe entities as objects. Typical objects may be customers, items, orders,
                                         and so on. Objects may also be GUI displays or text areas on the display.

                                         Classes
                                         Objects are typically part of a group of similar items called classes. The desire to place items into
                                         classes is not new. Describing the world as being made up of animals, vegetables, and minerals is an
                                         example of classification. The scientific approach includes classes of animals (such as mammals),
                                         and then divides the classes into subclasses (such as egg-laying animals and pouched mammals).
                                             The idea behind classes is to have a reference point and describe a specific object in terms
                                         of its similarities to or differences from members of its own class. In doing so, it is more effi-
                                         cient for someone to say “The koala bear is a marsupial (or pouched animal) with a large round
                                         head and furry ears” than it is to describe a koala bear by describing all its characteristics as a
                                         mammal. It is more efficient to describe characteristics, appearance, and even behavior in this
                                         way. When you hear the word reusable in the object-oriented world, it means you can be more
                                         efficient because you do not have to start at the beginning to describe an object every time it is
                                         needed for software development.
                                             Objects are represented by and grouped into classes that are optimal for reuse and maintain-
                                         ability. A class defines the set of shared attributes and behaviors found in each object in the class.
                                         For example, records for students in a course section have similar information stored for each
                                         student. The students could be said to make up a class (no pun intended). The values may be
                                         different for each student, but the type of information is the same. Programmers must define the
                                         various classes in the program they are writing. When the program runs, objects can be created
                                         from the established class. The term instantiate is used when an object is created from a class.
                                         For example, a program could instantiate a student named Peter Wellington as an object from the
                                         class labeled as Student.
                                             What makes object-oriented programming, and thus object-oriented analysis and design,
                                         different from classical programming is the technique of putting all of an object’s attributes and
                                         methods within one self-contained structure, the class itself. This is a familiar occurrence in the
                                         physical world. For example, a packaged cake mix is analogous to a class since it has the ingre-
                                         dients as well as instructions on how to mix and bake the cake. A wool sweater is similar to a
                                         class because it has a label with care instructions sewn into it that caution you to wash it by hand
                                         and lay it flat to dry.
                                             Each class should have a name that differentiates it from all other classes. Class names are
                                         usually nouns or short phrases and begin with an uppercase letter. In Figure 10.1 the class is
                                         called RentalCar. In UML, a class is drawn as a rectangle. The rectangle contains two other
                                         important features: a list of attributes and a series of methods. These items describe a class, the
                                         unit of analysis that is a large part of what we call object-oriented analysis and design.

              Figure 10.1                                                               Class Name
              An example of a UML class. A                      RentalCar
              class is depicted as a rectangle            size
              consisting of the class name,               color                         Attributes
              attributes, and methods.                    make
                                                          model
                                                          rentOut( )                    Methods (Operations)
                                                          checkIn( )
                                                          service( )
   282   283   284   285   286   287   288   289   290   291   292