By: D. Riehle
Published in: PLoPD2
Category: Creational, Structural
Summary: Encapsulation of class hierarchies behind their root classes.
Clients of an encapsulated class tree need to retrieve classes from that tree. Have the clients create a specification for classes they are interested in. The client requests all classes from the class tree that meet the specification.
An encapsulated class tree is of no use unless objects of its internal classes can be created. Clients only know the interface class and a property that unambiguously identifies the class they are interested in. The client of a class creates a specification that unambiguously identifies a single class, then requests a new instance of a class that fits the specification.
A class clause makes an atomic statement about a class property that is true or false. It is represented by an object and can be compared to other clauses. It provides a basis for class specifications and first-class representations of class semantics.
Clients use specifications to retrieve classes from a class tree. A class specification is a formula from propositional calculus with clauses as its basic constituents. Clients build a specification by creating clauses and using them in a formula.
Provide a set of clause instances for each class. Each clause makes a statement about the class. The set of clauses represents the semantics of the class. A class can be matched against a specification, which is realized by comparing clauses and evaluating the formula.