How to Identify Classes in Object-Oriented Analysis

A simple and effective way to discover classes is using a technique known as noun/verb analysis and grammatical checking. This involves thoroughly examining high-level requirement documents, marketing materials, and other sources that shed light on the problem domain (i.e., the domain defined by the problem the new system should solve).

See Using UML for Use Case-Driven Object Modeling for an example of how to perform grammatical checking on a set of textual requirements.

Many people use rapid prototyping as a tool to explore requirements with users. Let’s see how we can use a prototype HTML page for an Internet bookstore to identify a small subset of the classes needed in modeling the entire bookstore.

We start with a single page that displays detailed information about a specific book.

Quickly recalling this page in your mind reveals the following classes as appropriate:

  • Of course, there is a Book, at least one Author.
  • There is a Publisher.
  • The book may have one or more reviews. These reviews fall into two categories: EditorialReviews and CustomerReviews. (You’ll learn the difference in Chapter 2.) Each review has an associated Reviewer.

If we move forward and imagine a user purchasing the book after viewing the page, other potential classes come into view:

  • The viewer becomes a Customer and has an associated Account.
  • The book becomes part of an Order.
  • The order must have BillingInformation and ShippingInformation so the bookstore can collect payment and ship the book.

Further analysis reveals the need for the following two classes:

  • As mentioned, a book can have multiple authors, but an author can write more than one book. To avoid a many-to-many relationship, we need a BookAndAuthor class.

The bookstore (Book Store) uses various shipping companies (Shipper Companies), so a Shipper class is needed.

Thus, the resulting set of nouns (nouns) and noun phrases (noun phrases) includes:

  • Account
  • Author
  • BillingInfo
  • Book
  • BookAndAuthor
  • Customer
  • CustomerReview
  • EditorialReview
  • Order
  • Publisher
  • Review
  • Reviewer
  • Shipper
  • ShippingInfo
Note:

This example illustrates a fundamental principle: find as many nouns and noun phrases as possible from the requirements, then analyze, refine, and expand the list. No matter how you do it, identifying classes is a great way to kickstart your modeling journey.