A constraint is a Boolean condition bracketed by curly braces:
Reified Associations
Reification means the same thing as objectification or object-orientation. It is the practice of representing abstractions such as ideas, events, and relationships as objects (instead of functions or relationships, say).
Sometimes links between objects have attributes and need to be persistent (i.e., we need to be able to store them in files and databases). In these situations it makes sense to turn links into objects and associations into classes. We call such classes reified associations. Let's call instances of reified associations link objects.
For example, purchasing stock is a relationship between a person and a company:
In C++:
class Person
{
set<Company*>
holdings;
// etc.
};
The solution is to explicitly represent purchases as link objects instantiating a Purchases reified association:
In C++:
class Company
{
set<BuyShares*>
owners;
// etc.
};
class Person
{
set<BuyShares*>
holdings;
// etc.
};
Association classes are reified associations with an additional constraint. For example, a job is a relationship between a company and a person:
In C++ we might represent Job links as pointers:
class Person
{
Company*
employer;
// etc.
};
To solve this problem we can reify the Job association. Now Earl's bouncer job and programmer job are link objects: instances of a Job class. Each instance encapsulates a salary, an employer link, and an employee link. We can represent the Boss relationship as a Job self-association. Here is the UML notation:
In C++:
class Company
{
set<Job*>
jobs;
// etc.
};
class Person
{
set<Job*>
jobs;
// etc.
};
Although the Job class is a reified association similar to the Purchases class, there is an important difference: The same person can purchase stock from the same company many times, resulting in many Purchase objects. However, the same person can't have many jobs with the same company. In other words, two Job objects can't have the same employer and employee roles, but two Purchase objects can have the same holding and owner roles.
Follow this link to a mathematical example that some people may find helpful.