Participant-Transaction Pattern
The Participant-Transaction object association pattern connects a participant object such as a person or organization with a transaction object such as a sale or payment. People and organizations perform transactions very frequently. For example, students pay registration fees to take courses at a university. Figure 6.21 shows the Participant-Transaction pattern template and a Student-Course example of the pattern.
Place-Transaction Pattern
The Place-Transaction object association pattern connects
a place object such as a store, office or ticket window with a transaction object such as a sale or payment. Transactions are normally performed at locations including a website location. For example, students pay registration fees at a university cashier's window. Figure 6.22 shows the Place-Transaction pattern template and a registration fee being paid at a cashier's window example of the pattern. Figure 6.23 combines the Participant-Transaction pattern with the Place-Transaction pattern because these two patterns often exist in a real-world business problem domain.
Participant-Place Pattern
The Participant-Place object association pattern connects a participant object such as a person or organization with a place object such as a store, office or ticket window. Participants are normally organized by place. At some point in time each university student declares his or her major, which is "owned" by a particular college on the university campus—a Marketing major is usually "owned" by a College of Business Administration. Figure 6.24 shows the Participant-Place pattern template and a student belonging to a college within the university example of the pattern. This pattern may also be combined with the Participant-Transaction pattern because these two patterns often exist in real-world business problem domains.
Transaction-Transaction Line Item Pattern
The Transaction-Transaction Line Item object association pattern connects a transaction object such as a sale or order with a transaction line item object such as sale line item or order line item. Transactions usually have one or more transaction line items. For example, students paying full university registration fees have several "line items" that they are simultaneously paying for such as tuition, health, and student body fees. Figure 6.25 shows the Transaction-Transaction Line Item pattern template and the student registration fees to registration fees line items example of the pattern.
Item-Transaction Line Item Pattern
The Item-Transaction Line Item object association pattern connects an item object such as a product with a transaction line item object such as sale line item or order line item. Each transaction line item represents one specific item that is being purchased even though there may be more than one of these items being purchased—for example, someone purchases 10 Baby Ruth candy bars. Usinig the university
system as another example, the items that a university registration fees system is aware of are things like tuition, health, and student body fees. Each student's registration fee transaction will have one or more of these fees associated with it. Figure 6.26 shows the Item-Transaction Line Item pattern template and a master or reference list of registration fees along with the student's registration fees transaction example of the pattern.
This pattern is worthy of further discussion and illustration since it is a very common one in many business information systems. Transaction line items usually come from a master or reference list of items that are available to be included as a transaction line item. A master class of student registration fee objects might look something like the one in Figure 6.27. A transaction line item class that gets its registration fee items from the master student registration fees class might look something like the one also represented in Figure 6.27. As discussed in an earlier chapter, master or reference lists of items include customers, students, courses, products, faculty, rooms, and so on.
Peer-Peer Pattern
There is a significant amount of robustness in the use of object associations even though the ones already discussed may address a large majority of your problem domain needs. The Peer-Peer pattern is an object association between objects within the same class as shown in Figure 6.28. In this example, the user-determined policy was that a student could have zero, one, two,
or three room-mates; therefore, it is possible to look at your Student object instance and find out the names of your roommates, assuming you had one, two, or three as in this example.
VIDEO STORE EXAMPLE
The Video Store classes shown at the beginning of this chapter as Figure 6.1 can now be grouped according to patterns. The student-instructor systems analysis team working on this project identified several helpful patterns. First, two generalization class patterns were discovered as shown in Figure 6.29. In this figure, the top generalization pattern has three levels. The first two levels consisting of Inventory, SaleItem and RentalItem generalization classes are all abstract. The bottom level consisting of Video, Game, Concession Item and VCR are all classes that can instantiate objects. The four types of products—videos, games, concession items and VCRs—are all types of inventory that are either rented or sold. The middle-layer generalizations—SaleItem and RentalItem—were created to simplify the distribution of attributes between classes that had objects for sale—Video, Game and ConcessionItem—and classes that had objects for rent—Video, Game and VCR. Attributes associated with the sale of an inventory object could be promoted to the SaleItem class. Attributes associated with the rental of an inventory object could be promoted to the RentalItem class. Note that three abstract classes—included in Figure 6.1 for completeness sake—were created to become the generalization for this generalization pattern. The SaleItem and RentalItem are further discussed near the end of this section.
The second generalization pattern in Figure 6.29 combines sales and rental transactions. Like the prior generalization pattern, attributes that are common to both sales and rental transactions are promoted to the Transaction class.
Next, several object association patterns were discovered, some of which are shown in Figure 6.30. For example, the PurchaseOrder class had multi-valued attributes that led to the creation of the PurchaseOrderLineltem class. Also the discussion centered on the fact that not all products are sold and not all products are rented. To accommodate this, two new generalization classes—SaleItem and RentalItem—were introduced. All of the new classes were organized into the first pass of the problem domain's UML Class Diagram model and are now shown in Figure 6.31 as the final-pass UML Class Diagram. Finally, the list of all of the classes is shown in Figure 6.32.
At this point in the analysis of the Video Store information system, the instructor would present new material concerning operations. These topics are found in the next chapter of this book. After reviewing the material, the instructor would engage the students in another series of brainstorming sessions about the Video Store information system.
SUMMARY
This chapter addressed class and object responsibilities and patterns. There are dozens of patterns documented in various reference books, and many representative patterns were presented in the chapter beginning with the generalization pattern and followed by the various object association patterns. Following this, seven additional object association patterns that are common to business problem domains were presented. Finally, the Video Store UML Class Diagram was once again revisited as an example. Patterns can be useful to help
identify object relationships, which help support the "Who I know" object responsibility.
QUESTIONS
Note: These are not necessarily the correct questions for the new edition of this text!
6.1 Define and give an example of a generalization pattern.
6.2 Define and give an example of each of the three types of object association patterns:
Object association
Object aggregation association
Object composition association
6.3 Discuss the "whole-part" object association notion for each of these three perspectives: assembly-part, container-content, and group-member.
6.4 Define and give an example of the many-to-many pattern.
6.5 Define and give an example of the participant-transaction pattern.
6.6 Define and give an example of the place-transaction pattern.
6.7 Define and give an example of the participant-place pattern.
6.8 Define and give an example of the transaction-transaction line item pattern.
6.9 Define and give an example of the item-line item pattern.
6.10 Define and give an example of the peer-peer pattern.