The Object Constraint Language: Getting Your Models Ready for MDA (2nd Edition)

2.1 The "Royal and Loyal" System Example

As an example, we have modeled a computer system for a fictional company called Royal and Loyal (R&L). R&L handles loyalty programs for companies that offer their customers various kinds of bonuses. Often, the extras take the form of bonus points or air miles, but other bonuses are possible as well: reduced rates, a larger rental car for the same price as a standard rental car, extra or better service on an airline, and so on. Anything a company is willing to offer can be a service rendered in a loyalty program. Figure 2-1 shows the UML class model that R&L uses for most of its clients , which is a typical platform-independent model (PIM) within the context of MDA. It shows no dependency on whatever programming language that will be used to build the system.

Figure 2-1. The Royal and Loyal model

The central class in the model is LoyaltyProgram . A system that administers a single loyalty program will contain only one instance of this class. In the case of R&L, many instances of this class will be present in the system. A company that offers its customers membership in a loyalty program is called a ProgramPartner . More than one company can enter the same program. In that case, customers who enter the loyalty program can profit from services rendered by any of the participating companies.

Every customer of a program partner can enter the loyalty program by filling in a form and obtaining a membership card. The objects of class Customer represent the persons who have entered the program. The membership card, represented by the class CustomerCard , is issued to one person. Card use is not checked, so a single card could be used for an entire family or business. Most loyalty programs allow customers to save bonus points. Each individual program partner decides when and how many bonus points are allotted for a certain purchase. Saved bonus points can be used to "buy'' specific services from one of the program partners . To account for the bonus points that are saved by a customer, every membership can be associated with a LoyaltyAccount .

Various transactions on this account are possible. For example, the loyalty program "Silver and Gold" has four program partners: a supermarket , a line of gas stations , a car rental service, and an airline.

  • At the supermarket, the customer can use bonus points to purchase items. The customer earns five bonus points for any regular purchase over the amount of $25.

  • The gas stations offer a discount of 5 percent on every purchase.

  • The car rental service offers 20 bonus points for every $100 spent.

  • Customers can save bonus points for free flights with the airline company. For every flight that is paid for normally, the airline offers one bonus point for each 15 miles of flight.

In this situation, there are two types of transactions. First, there are transactions in which the customer obtains bonus points. In the model (see Figure 2-1), these transactions are represented by a subclass of Transaction called Earning . Second, there are transactions in which the customer spends bonus points. In the model, they are represented by instances of the Burning subclass of Transaction . The gas stations offer simple discounts but do not offer or accept bonus points. Because the turnover generated by the customers needs to be recorded, this is entered as two simultanous transactions on the LoyaltyAccount, one Earning and one Burning for the same number of points.

Customers in the Silver and Gold program who make extensive use of the membership are rewarded with a higher level of service: the gold card. In addition to the regular services, customers who have a gold card are also offered the following additional services:

  • Every two months, the supermarket offers an item that is completely free. The average value of the item is $25.

  • The gas stations offer a discount of 10 percent on every purchase.

  • The car rental service offers a larger car for the same price.

  • The airline offers its gold card customers a business class seat for the economy class price.

Customers must meet at least one of the following conditions to get a gold card:

  • Three sequential years of membership with an average annual turnover of $5,000

  • One year of membership with a turnover of $15,000, where the turnover is the total turnover with all program partners

To administer different levels of service, the class ServiceLevel is introduced in the model. A service level is defined by the loyalty program and used for each membership.

R&L advertises the program and its conditions. It manages all customer data and transactions on the loyalty accounts. For this purpose, the program partners must inform R&L of all transactions on loyalty program membership cards. Each year, R&L sends new membership cards to all customers. When appropriate, R&L upgrades a membership card to a gold card. In this case, R&L sends the customer a new gold card along with information about the additional services offered, and R&L invalidates the old membership card.

The customer can withdraw from the program by sending a withdrawal form to R&L. Any remaining bonus points are canceled and the card is invalidated. R&L can invalidate a membership when the customer has not used the membership card for a certain period. For the Silver and Gold program, this period is one year.

We could tell you more about R&L, but the preceding description is sufficient for our purposes. The diagram in Figure 2-1 outlines the system model. Now it's time to add the neccessary details by adding some expressions and stating a number of useful and indispensable constraints.

Категории