whether or not you use it today to make a payment. But if you don’t make a payment today, there is no payment amount. The existence of a payment amount is entirely dependent on the existence of a payment.
Figure 6.14shows the fact types thatOne Monetary Instrumentbuilds on.
Note that the fact typepayment has payment amountlooks different from the fact type payment employs monetary instrument. The property payment amount is drawn without a rectangle surrounding it. It is drawn that way because it is a property—a property ofpayment. The association betweenpay- mentand payment amountis labeled with “has,” and the fact typepayment has payment amountalso uses the word “has.” “Has” indicates that payment amount is a property of payment. “Has” is reserved just for properties. No non- property fact types use “has.”
No Checks:It is prohibited that a payment employ a personal check.
Whenever a payment employs a personal check,No Checksis violated.
Only operative business rules can be violated. Structural rules cannot. Struc- tural rules are true by definition, so a violation of a structural rule is impossible.
To see why, consider again the structural ruleVegetarian Menu Items B.
Vegetarian Menu Items B:It is possible that a vegetarian menu item includes an ingredient only if the ingredient is not meat and the ingredient is not fish.
Suppose a vegetarian menu item included a meat ingredient. That seems like it might be a violation ofVegetarian Menu Items B, but it is not. If a menu item includes a meat ingredient, the menu item is not vegetarian at all, by definition.
There is no violation because there is no vegetarian menu item.
Directly Enforceable
It must be possible for someone to decide whether a rule is being violated. If Joe knows a business rule and sees Emily do something, it should be possible for Joe to decide whether Emily’s action violates the rule or not. If a proposed rule does not admit this kind of decision, it is not a rule at all.
Let’s look at an example. At any Mykonos restaurant a customer can choose to give a tip to his server—a tip of any size. If the service if good, he might give 20 per- cent of the bill or even more. If the service is bad, he might give 5 percent or even nothing at all. It is all his choice. Unfortunately, in a large party, the server often gets stiffed; the customers collectively pay a small tip, much less than 10 percent. So, like many other restaurants, Mykonos specifies a minimum tip if the party is large.
Nonrule 1is an attempt to regulate that behavior through a business rule, but it does not succeed becauseNonrule 1is not a well-formed rule.
Nonrule 1: It is obligatory that the gratuity is at least 15% if the gratuity is applied to a bill and the bill is incurred by a party and the party is large.
The problem withNonrule 1is that it is not always possible to know whether the rule is being violated. Certainly a party of 24 is large, so if that party gives an 11 per- cent tip,Nonrule 1is violated. And certainly a party of two is not large, so even if they give nothing,Nonrule 1is not violated. But what if a party of six gives a 9 per- cent tip? Is a party of six large? What about a party of eight? A party of seven?
Nonrule 1is said to be notdirectly enforceable. A rule is directly enforceable if someone who knows the rule and sees some behavior can decide whether the rule is violated.Nonrule 1needs to be replaced by the directly enforceable rule Large Party Gratuity.
Large Party Gratuity:It is obligatory that the gratuity is at least 15% if the gratuity is applied to a bill and the bill is incurred by a party and the size of the party is greater than 7 people.
(Alternatively, the noun conceptlarge partycould be defined as a party whose size is greater than seven.)
Large Party Gratuityis directly enforceable. If Joe knowsLarge Party Gra- tuityand sees a party of six people apply a tip of 11 percent, he can determine thatLarge Party Gratuityis not violated. The party might be stingy, but they are not violating this rule.
Multiple Violations
Most operative rules can be violated in more than one way. Consider the follow- ing rule about menus, meant to ensure that vegetarians always have at least two choices on every menu at a Mykonos restaurant.
2 Vegetarian Entrees:It is obligatory that each menu include at least two veg- etarian entrees.
Obviously,2 Vegetarian Entreesis violated when Angela Glaser—the head chef at Zona—creates a new menu with only a single vegetarian entree. But there is a second, not so obvious situation when 2 Vegetarian Entrees is violated. Sup- pose a menu has two vegetarian entrees: linguini puttanesca and grilled eggplant with goat cheese. Now Angela decides to add anchovies to enhance the linguini puttanesca. This addition may well improve the taste of the dish, but it also makes the entree no longer vegetarian. Her change to the entree violates the2 Vegetar- ian Entreesrule.
A business rule shapes behavior when it is violated. Someone enforces the rule by noting the violation and explaining the rule to the violator. Or if the rule is enforced by an application, the application notes the violation and presents a dia- log box to the violator. But a business rule also shapes behavior before it is vio- lated, by the mere potential for violation. When our anchovy-happy Angela talks about her plan to a colleague, the colleague reminds Angela of 2 Vegetarian Entrees. Or Angela remembers the rule on her own and adds another vegetarian dish to the menu when she improves the linguini with anchovies. In either situa- tion, the mere potential for violation triggers the business rule.
A single change can violate more than one rule. Consider the rule Visible Allergens, meant to protect people who have food allergies.
Visible Allergens:It is obligatory that the description of a menu item includes an ingredient if the ingredient is a common allergen.
Fish is a common allergen, one of the eight recognized by the US Food and Drug Administration. If Angela adds anchovies to the puttanesca sauce and does not change the menu, she is not only making things more difficult for vegetarians, she is also endangering anyone allergic to fish. Her one seemingly innocent change violates two business rules: 2 Vegetarian Entrees and Visible Allergens.
164 CHAPTER 6 Business Rule Models
A violation of a business rule should be recognized as soon as possible. It does little good to recognize the violation ofVisible Allergensafter someone has an allergic reaction to a menu item that is inadequately described on the menu. It is better for the server to recognize the violation before the allergic customer orders the linguini. It is even better to recognize the violation before the menus are printed. And it is still better yet to recognize it when the change is being first con- templated, while the violation is still only a potential. With business rule viola- tions, early recognition is better.