UML By Example”The Book StoreThis section will describe a simple requirement for a Book Store system and explain how you can derive a use case from the requirements specification and the Activity, Class, and Interaction diagrams from the use case. The requirements for the Book Store system are as follows :
Deriving the Book Store Use Case DiagramAn analysis of the requirements will provide you with a list of Actors and how they will use the Book Store system; these are your use cases. The idea is to create as many use cases as necessary to fully describe the system requirements. Note There is not a one-to-one relationship between system requirements and use cases. The derived actors for the Book Store use case are as follows:
The derived use case scenarios for the Book Store are as follows:
Figure 3.36. Use Case diagram: Browse the book store catalog.
Most likely your projects will have multiple use cases from which to derive the design. The objective is to realize each use case into a system design in a methodical manner using UML. Trying to design all of the classes for the entire application at the same time would be an overwhelming and discouraging undertaking. Also, in the real world, you will be working with a group of developers, where each developer can concurrently design different parts of the application from individual use cases. Deriving the Book Store Activity DiagramFrom the use case, the next step is to create an Activity diagram. This will give you a more complete understanding of the use case before creating Class diagrams. The Activity diagram maps very well to the scenario and alternatives given by a use case. The Book Store Activity diagram is illustrated in Figure 3.37. Figure 3.37. The Book Store Activity diagram.
The swimlanes in the Activity diagram show who is performing the actions. The Customer performs "search catalog" which causes a transition to Catalog to "perform query." A decision is used to indicate the alternative flow requiring "fill out form" to be performed by the Customer. Deriving the Book Store Class DiagramTo derive a Class diagram, you must refer to the Use Case and Activity diagrams. The Activity diagram in Figure 3.37 indicates the Customer has an association with the Catalog. The Use Case specification indicates that a customer must provide an operation to search the catalog. This requirement, in turn , shows the need for a Book object that is returned from the search. Now that you have reviewed and evaluated the Activity diagram, you can create your Class diagram. Figure 3.38 illustrates the realization of the Book Store Use Case in the form of a Class diagram. Figure 3.38. The Book Store Class diagram.
From Figure 3.38, you can identify the following:
Deriving the Book Store Interaction DiagramsAs you may have guessed, the Book Store Sequence diagram, Figure 3.39, was completely generated by the Together ControlCenter. This tool enables you to generate a Sequence diagram from selected methods in a Class diagram. This is an extremely powerful capability of the design tool. The generated Sequence diagram is also shown as a Collaboration diagram in Figure 3.40, which was also auto-generated by the Together ControlCenter. Figure 3.39. The Book Store Sequence diagram.
Figure 3.40. The Book Store Collaboration diagram.
|