Basic Relationship Patterns


By: J. Noble
Published in: PLoPD4
Pages: 73-89
Category: Behavioral

Summary: How objects can model relationships in programs.

Pattern: Relationship as Attribute

Pages: 76-78

To design a small, simple, one-to-one relationship, make an attribute to represent the relationship.

Pattern: Relationship Object

Pages: 78-80

Use a relationship object to represent a large, complex relationship.

Pattern: Collection Object

Pages: 80-82

Use a Collection to design a one-to-many relationship.

Pattern: Active Value

Pages: 82-84

To design a globally important one-to-one relationship, make an active value, an object that reifies a single variable. It should have an attribute to hold the variable's value with an accessor and a set method.

Pattern: Mutual Friends

Pages: 84-88

To represent a two-way relationship, make a consistent set of one-way relationships.