UML By ExampleThe Book Store


UML By Example”The Book Store

This 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 :

  • A Customer can browse a catalog of all available books.

  • A Customer can search for books by title or author.

Deriving the Book Store Use Case Diagram

An 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:

  • Customer

  • Catalog

The derived use case scenarios for the Book Store are as follows:

  • Use Case 1: The customer browses the catalog.

    The Book Store enables customers to browse all entries in the catalog. The only error condition is that the customer does not find any books of interest. The alternative flow requests the customer to fill out a survey.

  • Use Case 2: The book store enables customers to search the catalog by title and author.

    This use case has the same alternative flow as Use Case 1. In fact, browsing the catalog can be thought of as searching for every book by every author. Use Case 2 is actually a specialization of Use Case 1. The Use Case diagram, as illustrated in Figure 3.36, visualizes this relationship as a generalization .

Figure 3.36. Use Case diagram: Browse the book store catalog.

graphics/03fig36.gif

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 Diagram

From 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.

graphics/03fig37.gif

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 Diagram

To 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.

graphics/03fig38.gif

From Figure 3.38, you can identify the following:

  • Customer has an association with Catalog .

  • Catalog has a composition of multiplicity 0..* to the Book class.

Deriving the Book Store Interaction Diagrams

As 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.

graphics/03fig39.gif

Figure 3.40. The Book Store Collaboration diagram.

graphics/03fig40.gif



BEA WebLogic Platform 7
BEA WebLogic Platform 7
ISBN: 0789727129
EAN: 2147483647
Year: 2003
Pages: 360

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