In this article you will learn about the Unified Modeling Language (UML) by examining basic modeling of things and concepts in the real world. It is excerpted from the book Fast Track UML 2.0, written by Kendall Scott (Apress, 2004; ISBN: 1590593200)
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 UML4 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:
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.