Adding Modeling Elements to the Class Diagram - Practices
This article provides an overview of the practical application of object-oriented analysis and design (OOAD) design concepts and the Unified Modeling Language (UML). It is taken from chapter two of the book Enterprise Java Development on a Budget, written by Brian Sam-Bodden and Christopher M. Judd (Apress, 2004; ISBN: 1590591259)
The next step is to graphically construct the model. Renowned object technologist Martin Fowler defines a domain model as “an object model of the domain that incorporates both behavior and data.”15
A domain model creates a web of interconnected objects, where each object represents some meaningful entity, whether it’s as large as a corporation or as small as a single entry in a user’s schedule. This seemingly static model is represented with a class diagram that shows the basic relationships between the candidate elements. A class diagram models structure and contents using design elements such as classes, packages, and objects. It also displays relationships such as containment, inheritance, associations, and others.
The slight difference in this approach from the traditional static domain entity model is that you’ll be adding relationships between entity classes in the form of moment-interval classes, and you’ll be identifying any other classes as belonging to one of the four Coad archetypes.
Let’s start with a small section of the domain, focusing on the session m-i candidate as shown in Table 2-3. Your basic strategy is to identify some m-i classes and plug other archetypes around them using the DNC as guide.
To add a new class to the diagram, follow these simple steps:
Select the diagram on the Navigator pane (entitled “Class Diagram”).
Click the class icon in the toolbar (yellow square with three compartments).
Click anywhere on the Editor pane.
The new unnamed class element should appear on the Editor pane at the location of the last mouse click as well as in the Explorer. Select the Properties tab on the Details pane and in the Name field enter person. Repeat these steps for the following classes: Presenter, Attendee, Session, SessionLocation, ContentToBePresented, Room, and Presentation. The class diagram should now resemble Figure 2-9.
Figure 2-9.Newly created classes
The next step is to associate the created classes with one of the four archetypes. To date the only tool that includes built-in support for the Color in UML techniques, the four basic archetypes, and the DNC is Borland’s Together line of products, formerly TogetherSoft’s TogetherJ. ArgoUML enables the creation of custom stereotypes and also enables a class color to be selected. Although at this point it isn’t possible to associate a specific stereotype with a class color or any other attribute. Therefore, for each class you need to manually assign a color. This is a small price to pay for the extra expressiveness that color brings into the process.
Creating a Custom Stereotype
Adding a new stereotype to ArgoUML is a little trickier than it needs to be (we expect the procedure to be simplified in future versions):
Select any class in the class diagram.
On the Details pane choose the Property tab and select any stereotype from the stereotype drop-down list.
Click the button next to the drop-down list. The button is unlabeled with a graphic of an arrow with a 90-degree bend. This should take you to the stereotype Property tab.
Click the New Stereotype button (the one adorned with guillemets).
Enter the name of the new stereotype, in this case enter party.
Repeat the last two steps shown previously for the following stereotypes: place, thing, role, moment-interval, and description.
The ArgoUML manual cautions about a known bug. Apparently, in certain versions of ArgoUML the newly created stereotypes will not appear in the class property stereotype drop-down list until the entire model is saved and then reloaded.