Almost every object model I see seems to deal in the now and does not deal with the past or the future.
Consider a relationship that crops up in almost every object model, a person and an address. A model usually resolves this relationship by saying that a person has an address. The reality is usually more complicated.
If one starts addressing the temporal element the model starts to get more interesting. A more accurate way of modelling is to say that a person has an address at a particular point in time. People move houses all the time.
The most robust way of modelling this is using a time constrained relationship. The object representing this relationship consists of the following attributes:
- The person.
- The address.
- The point in time that the relationship starts.
- The point in time that the relationship ends.
The first three attributes are mandatory, the last is optional. The most recent address is the one with no relationship end time. The current address is the one whose relationship includes now.
This allows us behaviours that are extremely useful in a business sense. One can work out the address a pay cheque went to or a change of address notification can be filed and automatically used when the move occurs.
Temporal modelling is an essential part of object modelling and should never be ignored.
No comments:
Post a Comment