Discovering Classes


A simple yet effective way to discover classes uses a technique variously known as noun/verb analysis and grammatical inspection. This involves poring through high-level requirements documents, marketing materials, and other materials that provide insight into the problem domain (in other words, the arena defined by the problem that the new system is supposed to solve). See Use Case Driven Object Modeling with UML [4] for an example of how to perform grammatical inspection using a set of text requirements.

Many people use rapid prototyping as a device for exploring requirements with users. Let's see how we might use a prototype HTML page for an Internet bookstore to discover a small subset of the classes we'll need in modeling the bookstore as a whole. We start with a page that displays the details of a particular book.

A quick mental review of the page reveals the following obvious candidates for classes:

  • There's a Book, of course, and at least one Author.

  • There's a Publisher.

  • There may be one or more Reviews of the Book. These Reviews fall into one of two categories: EditorialReviews and CustomerReviews. (You see how to make this distinction in Chapter 2.) Each Review has a Reviewer associated with it.

If we move ahead and envision the viewer of this page purchasing the Book, the following other potential classes come into view:

  • The viewer becomes a Customer, with an associated Account.

  • The Book becomes part of an Order.

  • The Order has to have BillingInformation and ShippingInformation in order for the bookstore to get paid and to ship the book.

Analyzing a little more deeply reveals the need for the following two other classes:

  • A Book can have more than one Author, as I've noted, but an Author can have more than one Book, too. In the interest of avoiding many-to-many relationships, we need a BookAndAuthor class. (You see how to represent this class in Chapter 2.)

  • The bookstore uses various shipping companies, so there needs to be a Shipper class.

The result, then, is the following set of nouns and noun phrases:

  • Account

  • Author

  • BillingInfo

  • Book

  • BookAndAuthor

  • Customer

  • CustomerReview

  • EditorialReview

  • Order

  • Publisher

  • Review

  • Reviewer

  • Shipper

  • ShippingInfo

Note ‚  

This example is representative of a fundamentally sound idea: Find as many nouns and noun phrases as possible to start, and only analyze, refine, and expand the list later. Regardless of how you go about it, though, discovering classes is an excellent way to get your modeling off to a good start.

[4] Doug Rosenberg with Kendall Scott, Use Case Driven Object Modeling with UML (Boston, MA: Addison-Wesley, 1999).




Fast Track Uml 2.0
Fast Track UML 2.0
ISBN: 1590593200
EAN: 2147483647
Year: 2004
Pages: 97

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