Team LiB
Previous Section Next Section

Determining Associations Between Classes

Once we've settled on an initial candidate class list, the next step is to determine how these classes are interrelated. To do this, we go back to our narrative documentation set (which has grown to consist of the SRS requirements specification, use cases, and data dictionary) and study verb phrases this time. Our goal in looking at verb phrases is to choose those that suggest structural relationships, as were defined in Chapter 5—associations, aggregations, and inheritance—but to eliminate or ignore those that represent (transient) actions or behaviors. (We'll focus on behaviors, but from the standpoint of use cases, in Chapter 11.)

For example, the specification states that a student "chooses a faculty advisor." This is indeed an action, but the result of this action is a lasting structural relationship between a professor and a student, which can be modeled via the association "a Professor advises a Student."

As a student's advisor, a professor also meets with the student, answers the student's questions, recommends courses for the student to take, approves his or her plan of study, etc.—these are behaviors on the part of a professor acting in the role of an advisor, but don't directly result in any new relationships being formed between objects.

Let's try the verb phrase analysis approach on the requirements specification. We've highlighted all relevant verb phrases in the sidebar that follows (note that we omitted such obviously irrelevant verb phrases as "We've been asked to develop an automated SRS ").

Let's scrutinize a few of these:

and so on.

Association Matrices

Another complementary technique for both determining and recording what the relationships between classes should be is to create an n ?n association matrix, where n represents the number of candidate classes that we've identified. Label the rows and the columns with the names of the classes, as shown for the empty matrix represented by Table 10-1.

Table 10-1: An "Empty" Association Matrix for the SRS
?/td>

Section

Course

PlanOfStudy

Professor

Student

Transcript

Section

?/td>?/td>?/td>?/td>?/td>?/td>

Course

?/td>?/td>?/td>?/td>?/td>?/td>

PlanOfStudy

?/td>?/td>?/td>?/td>?/td>?/td>

Professor

?/td>?/td>?/td>?/td>?/td>?/td>

Student

?/td>?/td>?/td>?/td>?/td>?/td>

Transcript

?/td>?/td>?/td>?/td>?/td>?/td>

Then, complete the matrix as follows.

In each cell of the matrix, list all of the associations that you can identify between the class named at the head of the row and the class named at the head of the column. For example, in the cell highlighted in Table 10-2 at the intersection of the Student "row" and the Section "column," we have listed three potential associations:

  • A Student is waitlisted for a Section.

  • A Student is registered for a Section (this could be alternatively phrased as "a Student is currently attending a Section").

  • A Student has previously taken a Section: This third association is important if we plan on maintaining a history of all of the classes that a student has ever taken in his or her career as a student, which we must do if we are to prepare a student's transcript online. (As it turns out, we'll be able to get by with a single association that does "double duty" for the latter two of these, as we'll see later on in this chapter.)

Table 10-2: Our Completed Association Matrix
?/td>

Section

Course

PlanOfStudy

Professor

Student

Transcript

Section

?/p>

instance of

?/p>

is taught by

included in

Course

prerequisite for

is called for by

?/p>

?/p>

PlanOfStudy

?/p>

calls for

?/p>

?/p>

observed by

?/p>

Professor

teaches

?/p>

?/p>

?/p>

advises; teaches

?/p>

Student

registered for; waitlisted for

plans to take; has previously taken

observes

is advised by; studies under

?/td>

owns ?/i>

Transcript

includes

?/p>

?/p>

?/p>

belongs to

?/p>

Mark a cell with an ?if there are no known relationships between the classes in question, or if the potential relationships between the classes are irrelevant. For example, we've marked the cells representing the intersection between Professor and Course with an ? even though there is an association possible—"a Professor is qualified to teach a Course"—because it isn't relevant to the mission of the SRS.

We mentioned in Chapter 4 that all associations are inherently bidirectional. This implies that if a cell in row j, column k indicates one or more associations, then the cell in row k, column j should reflect the reciprocal of these relationships. For example, since the intersection of the PlanOfStudy "row" and the Course "column" indicates that "a PlanOfStudy calls for a Course," then the intersection of the Course "row" and the PlanOfStudy "column" must indicate that "a Course is called for by a PlanOfStudy."

It's not always practical to state the reciprocal of an association; for example, our association matrix shows that "a Student plans to take a Course," but trying to state its reciprocal—"a Course is planned to be taken by a Student"—is quite awkward. In such cases where a reciprocal association would be awkward to phrase, simply indicate its presence with the symbol .

We'll be portraying these associations in graphical form shortly! For now, we'd want to go back and extend our data dictionary to explain what each of these associations means; here's one such example:

Identifying Attributes

To determine what the attributes for each of our domain classes should be, we make yet another pass through the requirements specification looking for clues. We already stumbled upon a few attributes earlier, when we weeded out some nouns/noun phrases from our candidate class list:

  • For the Section class, we identified "day of week", "room", "seating capacity", "semester", and "time of day" as attributes.

  • For the Student class, we identified "degree" as an attribute.

We can also bring any prior knowledge that we have about the domain into play when assigning attributes to classes. Our knowledge of the way that universities operate, for example, suggests that all students will need some sort of student ID number as an attribute, even though this isn't mentioned anywhere in the SRS specification. We can't be sure whether this particular university assigns an arbitrary student ID number, or whether the policy is to use a student's social security number (SSN) as his or her ID; these are details that we'd have to go back to our end users for clarification on.

Finally, we can also look at how similar information has been represented in existing legacy systems for clues as to what a class's attributes should be. For example, if a Student Billing System already exists at the university based on a relational database design, we might wish to study the structure of the relational database table housing student information. The columns that have been provided in that table—name, address, birthdate, etc.—are logical attribute choices.


Team LiB
Previous Section Next Section