Page 313 -
P. 313

280     Part 3  •  the analysis Process

                                         simple version and does not include employees who are students and students who work for the
                                         university. If these were added, they would be subclasses of the Employee and Student classes.
                                         Employee has two subclasses, Faculty and Administrator, because there are different attri-
                                         butes and methods for each of these specialized classes.
                                             Subclasses have special verbs to define them. These are often run-on words, such as isa for
                                         “is a,” isakinda for “is a kind of,” and canbea for “can be a.” There is no distinction between “is
                                         a” and “is an”; they both use isa.

                                                          isa          Faculty isa Employee
                                                          isakinda     Administrator isakinda Employee
                                                          canbea       Employee canbea Faculty


                                         idEntifyinG aBstraCt ClassEs.  You may be able to identify abstract classes by looking to
                                         see if a number of classes or database tables have the same elements or if a number of classes
                                         have the same methods. You can create a general class by pulling out the common attributes and
                                         methods, or you might create a specialized class for the unique attributes and methods. Using a
                                         banking example, such as a withdrawal, a payment on a loan, or a check written, will all have the
                                         same method—subtracting money from the customer balance.
                                         findinG ClassEs.  There are a number of ways to determine classes. They may be discovered
                                         during interviewing or JAD sessions (described in Chapter 4), during facilitated team sessions,
                                         or from brainstorming sessions. Analyzing documents and memos may also reveal classes.
                                         One of the easiest ways is to use the CRC method described previously in this chapter. An
                                         analyst should also examine use cases, looking for nouns. Each noun may lead to a candidate, or
                                         potential, class. They are called candidate classes because some of the nouns may be attributes
                                         of a class.
                                             Each class should exist for a distinct object that has a clear definition. An analyst should ask
                                         what the class knows (the attributes) and what the class knows how to do (the methods). The
                                         analyst should identify class relationships and the multiplicity for each end of the relationship. If
                                         the relationship is many-to-many, the analyst should create an intersection or associative class,
                                         similar to the associative entity in an entity-relationship diagram.
                                         dEtErmininG Class  mEthods.  An analyst must determine class attributes and methods.
                                         Attributes are easy to identify, but the methods that work with the attributes may be more difficult.
                                         Some of the methods are standard and are always associated with a class, such as the new() method
                                         or the «create» method, which is an extension to UML called a stereotype. (The « » symbols are not
                                         simply pairs of greater than and less than symbols; they are called guillemots or chevrons.)
                                             Another useful way to determine methods is to examine a CRUD matrix (see Chapter 7).
                                         Figure 10.21 illustrates a CRUD matrix for course offerings. Each letter requires a different
                                         method. If there is a C for create, you add a new() method. If there is a U for update, you add an
                                         update() or change() method. If there is a D for delete, you add a delete() or remove() method. If
                                         there is an R for read, you add methods for finding, viewing, or printing. In the example shown,
                                         the textbook class would need a create a method to add a textbook and a read method to initiate
                                         a course inquiry, change a textbook, or find a textbook. If a textbook were replaced, an update
                                         method would be needed, and if a textbook were removed, a delete method would be required.

                                         mEssaGEs.  In order to accomplish useful work, most classes need to communicate with one
                                         another. An object in one class can send information to an object in another class by using
                                         a message, similar to a call in a traditional programming language. A message also acts as a
                                         command, telling the receiving class to do something. A message consists of the name of the
                                         method in the receiving class, as well as the attributes (parameters or arguments) that are passed
                                         with the method name. The receiving class must have a method corresponding to the message
                                         name.
                                             Since messages are sent from one class to another, they may be thought of as an output or
                                         an input. The first class must supply the parameters included with the message, and the second
                                         class uses the parameters. If a physical child data flow diagram exists for the problem domain,
                                         it may help to discover methods. The data flow from one primitive process to another represents
                                         the message, and the primitive processes should be examined as candidate methods.
   308   309   310   311   312   313   314   315   316   317   318