Iterating Through the Design Process

 < Day Day Up > 



Creating Class Diagrams

Given the information provided in table 20-1 and the assurance gained from the analysis of the partial application architecture use case of figure 20-11 we can begin a more detailed design effort. A good place to begin this effort is by modeling the overall application package architecture. This will give you a guiding light or road map as you progress further with your design.

Creating an Overall Package Architecture Diagram

Figure 20-12 shows an overall robot rat application package architecture diagram. The package diagram is just a class diagram showing only the high-level package structure of the application. As you add classes later in the design process you can logically group them according to their package location.

click to expand
Figure 20-12: Overall Robot Rat Application Package Architecture

You create a new class diagram in Describe™ the same way you create a use case diagram, except in the drop down box choose Class Diagram. You will find the class diagram artifacts in the tool bar. Click the Package icon to create each package. As you can see from figure 20-12 I have identified five packages for my solution to the robot rat project. They are listed in table 20-2.

Table 20-2: Robot Rat Application Package Names and Their Purpose

Package Name

Purpose

Remote Controlled Object

The remote controlled object package contains all classes necessary to implement a remote controlled object.

Rodent

The rodent package contains all classes necessary to implement remote controlled rodents like RobotRat.

Rodent World

The rodent world package contains the class or classes necessary to implement the robot rat manager class. Rodent world seemed like a good name for the robot rat manager class.

Controller

The controller package contains all the classes necessary to implement the controller object.

User Interface

The user interface package contains all the classes necessary to implement the user interface.

Moving Beyond the Package Diagram

Using the overall package diagram as a guide you can now begin to define the classes that belong to each package. I will start with the Remote Controlled Object package and work on its associated classes. You can create a new class diagram for each package or create an overall class diagram and annotate the diagram in some way to denote what package each class or set of classes belong to. In this example I choose the overall diagram approach. Figure 20- 13 shows the beginning of the overall class diagram.

click to expand
Figure 20-13: Class Diagram Showing Remote Controlled Object Package Classes

At this stage of the detailed design you can postpone the consideration of individual class functions and attributes until you have fleshed out the classes and their relationships.

The class diagram shown in figure 20-13 implements the partial architectural use case diagram shown previously in figure 20-11 with the addition of two abstract base classes: AbstractPosition and AbstractMarker. The RemoteControlledObject class is an aggregate containing a Position object and a Marker object.

Adding Operations and Attributes to Classes

When you have a set of classes and their static relationship captured in a diagram you can begin to add methods and attributes to each class. Figure 20-14 shows the Properties Editor window for the AbstractPosition class.

click to expand
Figure 20-14: Properties Editor for AbstractPosition Class

To add operations to the class click on the Operations tab, then click on the New button. This will bring up another Properties Editor window. Figure 20-15 shows the Properties Editor window for the AbstractPosition constructor.

click to expand
Figure 20-15: Properties Editor Window for the AbstractPosition Operation

Describe™ will automatically generate code for class constructors and destructors if you make the necessary setting prior to code generation, however, the default generated constructors and destructors may not be satisfactory for your purposes.

Figure 20-15 shows the AbstractPosition operation, which is a constructor, being created. The Properties Editor window is used to set the name of the operation, its return type if needed, its visibility, stereotype, etc. In my approach to the robot rat design I wanted to create an abstract base class named AbstractPosition which has an inline constructor and destructor and its remaining functions pure virtual. Notice the settings used here to create the proper constructor. Compare these settings with those used in figure 20-16 below to create a pure virtual function named setRow.

click to expand
Figure 20-16: Properties Editor Window for the setRow() Function

Notice the return type is set to void, the visibility is public, and the type is set to Abstract. The setRow() function will have one integer parameter. To define function parameters click the Parameters tab in the Properties Editor window. This will reveal the Parameters section of the Properties Editor window as shown in figure 20-17.

click to expand
Figure 20-17: Adding Operation Parameters Using the Properties Editor Window

To add a parameter simply type in the parameter type followed by the parameter name. When you have finished adding operations, parameters, or editing other operation attributes click the OK button.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net