Java Reference
In-Depth Information
Relational Integrity
An object model is relationally consistent if every time object a points to object b ,
object b points to object a . For a more rigorous definition, consider two classes:
Alpha and Beta . Let A represent the set of objects in the model that are instances
of class Alpha , and let B represent the set of objects that are instances of class
Beta . Let a and b denote members of A and B, and let the ordered pair ( a , b )
denote that object a A has a reference to object b B. This reference may be either
a direct reference or one of a set of references, as when object a has a List object
that includes b .
The Cartesian product A x B is the set of all possible ordered pairs ( a , b ) with a A
and b B. The sets A and B allow the two Cartesian products A x B and B x A. An
object model relation on A and B is the subset of A x B that exists in an object
model. Let AB denote this subset, and let BA denote the subset of B x A that exists in
the model.
A x B has an inverse R -1
Any binary relation R
B x A defined by:
The inverse of AB provides the set of references that must occur from instances of B
to instances of A if the object model is consistent. In other words, instances of
classes Alpha and Beta are relationally consistent if and only if BA is the inverse
of AB.
Relational Integrity Mediators
Part of the strength of the object-oriented paradigm is that it lets you easily map connections
between Java objects and objects in the real world. However, a Java object model's ability to
reflect the real world has at least two fundamental deficits. First, objects in the real world vary
with time, but no support for this is built into Java. For example, assignment statements
obliterate any previous value instead of remembering it, as a human would. Second, in
the real world, relations are as important as objects, but relations receive little support in
today's object-oriented languages, including Java. For example, there is no built-in support for
the fact that if Star Press 2402 is in bay 1, bay 1 must contain Star Press 2402. In fact, it is
quite possible for such relations to go awry in Java, which in turn invites the application of
the M EDIATOR pattern.
Table 10.1. Modeling a Relationship
TUB
MACHINE
T305
StarPress-2402
T308
StarPress-2402
T377
ShellAssembler-2301
T379
ShellAssembler-2301
Search WWH ::




Custom Search