Home > Articles > Software Development & Management > Object Technology

  • Print
  • + Share This
This chapter is from the book

Classes—What They Do and How to Find Them

Classes are the vocabulary and terminology of an area of knowledge. As you talk with clients, analyze their area of knowledge, and design computer systems that solve problems in that area, you learn the terminology and model the terms as classes in the UML.

In your conversations with clients, be alert to the nouns they use to describe the entities in their business. Those nouns will become the classes in your model. Be alert also to the verbs that you hear because these will constitute the operations in those classes. The attributes will emerge as nouns related to the class nouns. After you have a core list of classes, question the clients as to what each class is supposed to do within the business. Their answers will tell you the class responsibilities.

Suppose you're an analyst building a model of the game of basketball, and you're interviewing a coach in order to understand the game. The conversation might go something like this:

Analyst: "Coach, what's basketball all about?"

Coach: "The goal of the game is to shoot the ball through the basket and score more points than your opponent. Each team consists of five players: two guards, two forwards, and a center. Each team advances the ball toward the basket with the objective of ultimately shooting the ball through the basket."

Analyst: "How does it advance the ball?"

Coach: "By dribbling and passing. But the team has to take a shot at the basket before the shot clock expires."

Analyst: "Shot clock?"

Coach: "Yes. That's 24 seconds in the pros, 30 seconds in international play, and 35 seconds in college to take a shot after a team gets possession of the ball."

Analyst: "How does the scoring work?"

Coach: "Each basket counts two points, unless the shot is from behind the three-point line. In that case, it's three points. A free throw counts one point. A free throw, by the way, is the penalty a team pays for committing a foul. If a player fouls an opponent, play stops and the opponent gets to shoot at the basket from the free-throw line."

Analyst: "Tell me a little more about what each player does."

Coach: "The guards generally do most of the dribbling and passing. They're typically shorter than the forwards, and the forwards are usually shorter than the center. All the players are supposed to be able to dribble, pass, shoot, and rebound. The forwards do most of the rebounding and intermediate-range shooting, while the center stays near the basket and shoots from close range."

Analyst: "How about the dimensions of the court? And by the way, how long does a game last?"

Coach: "In international play, the court is 28 meters long by 15 meters wide. The basket is 10 feet off the ground. In the pros, a game lasts 48 minutes, divided into four 12-minute quarters. In college and international play, it's 40 minutes divided into two 20-minute halves. A game clock keeps track of the time remaining."

This could go on and on, but let's stop and take stock of where we are. Here are the nouns you've uncovered: ball, basket, team, players, guards, forwards, center, shot, shot clock, three-point line, free throw, foul, free-throw line, court, and game clock.

Here are the verbs: shoot, advance, dribble, pass, foul, and rebound. You also have some additional information about some of the nouns—like the relative heights of the players at each position, the dimensions of the court, the total amount of time on a shot clock, and the duration of a game.

Finally, your own commonsense knowledge could come into play as you generate a few attributes on your own. You know, for example, that the ball has attributes like volume and diameter.

Using this information, you can create a diagram like the one in Figure 3.15. It shows the classes, and provides some attributes, operations, and constraints. The diagram also shows responsibilities. You could use this diagram as a foundation for further conversations with the coach, to uncover more information.

Figure 3.15Figure 3.15 An initial class diagram for modeling the game of basketball.

  • + Share This
  • 🔖 Save To Your Account