|I l @ ve RuBoard|
A class is a description of a group of objects with common properties (attributes), common behavior (operations), common relationships to other objects, and common semantics. Thus, a class is a template to create objects. Each object is an instance of some class and objects cannot be instances of more than one class. For example, the CourseOffering class may be defined with the following characteristics:
Algebra 101, Section 1, and Algebra 101, Section 2 are objects belonging to the CourseOffering class. Each object would have a value for the attributes and access to the operations specified by the CourseOffering class.
A good class captures one and only one abstractionit should have one major theme. For example, a class that has the capability of maintaining information about a student and the information about all the course offerings that the student has taken over the years is not a good class since it does not have one major theme. This class should be split into two related classes: Student and StudentHistory.
Classes should be named using the vocabulary of the domain. The name should be a singular noun that best characterizes the abstraction. Acronyms may be used if the acronym has the same meaning for all involved, but if an acronym has different meanings for different people then the full name should always be used. If a class is named with an acronym, the full name should also be contained in the class documentation.
It is often hard to distinguish between an object and a class. Why is Algebra 101, Section 1 an object and not a class? What makes it different from Algebra 101, Section 2? The answers to these questions are very subjective . By looking at their structure and behavior, it can be seen that both have the same structure and behavior. They are only different course offerings for a semester. In addition, it may be noted that there are many other "things" in the Course Registration System that have the same structure and behavior (e.g., Music 101, Section 1; History 101, Section 1; and History 101, Section 2). This leads to the decision to create a CourseOffering class.
In the UML, classes are represented as compartmentalized rectangles. The top compartment contains the name of the class, the middle compartment contains the structure of the class (attributes), and the bottom compartment contains the behavior of the class (operations). A class is shown in Figure 4-2.
CREATING CLASSES IN THE ROSE BROWSER
Figure 4-2. UML Notation for a Class
The browser view of a class is shown in Figure 4-3.
Figure 4-3. Class Created in the Browser
|I l @ ve RuBoard|