Pattern name: Class Graph

Purpose:

Classes and their structural relationships 
are used in numerous ways during software
development. Therefore, it is important that they be stored explicitly
in one place from where they can be accessed.
To make your application more robust to changes in class structure,
automate the definition of class graph induced operations such as
basic class definitions with get and set functions, constructors,
copying, displaying, printing, checking etc. 
Couple the rest of the application only loosely to the class graph
so that it is robust to class graph changes.


Also known as:

Class Diagram, Class Dictionary

Applicability:

For every application one or several class graphs are needed.


Implementation:

A variety of formalism are available to define class graphs
from the 30 plus design methods.

Provide the class graph induced operation implementations by a tool
which translates the class graph.
Some of the class graph induced operations are best
implemented using the Structure-Shy-Traversal and Selective
Visitor Pattern.
For example, generic object printing is best implemented by
generating a visitor class from the class dictionary.
Objects of this class can be attached to appropriate traversals
which select the parts of the objects which need to be printed.
See
http://www.ccs.neu.edu/research/demeter/sources/DemeterJava/examples/j-gprint/gprint

how to implement the printing visitor generation adaptively. See file
README-PROJ for explanation.
See
http://www.ccs.neu.edu/research/demeter/sources/DemeterJava/sourceC++/Java
for the Demeter/Java source needed to create the printing visitors.
The Demeter/Java source also shows an example of how to generate
the class definitions from the class graph.


Related Patterns:

Structure-shy Object.
The Reflection pattern [Siemens]: the class graph may be 
viewed as a meta object.


Known Uses:

Demeter Tools, Rational Rose, etc.

===========
K.Koskimies, H.Moessenboeck: Designing a Framework by Stepwise
Generalization. Proc. of the European Software Engineering Conference
ESEC'95, Sitges, Spain, Sept. 1995, Lecture Notes in Computer Science 989,
pp. 479-497
===========

The concept of a regular class system corresponds to a flat class graph.


References

Chapter 6 in [DEM] describes the pattern in detail.
For further references, check the bibliographic section of
that chapter.

Siemens:
@BOOK{buschmann:pattern-oriented,
AUTHOR = "Frank Buschmann et al.",
TITLE = "Pattern-oriented Software Architecture",
PUBLISHER = "John Wiley and Sons",
YEAR = "1997",
SERIES = "",
VOLUME = "",
NOTE = "ISBN = 0-471-95869-7"
}


Exercise

Develop a textual language to describe class graphs.
As source of ideas use existing OO methods such as Booch, OMT
or Fusion. Or use the Unified Modeling Language as a
source of ideas. Write a grammar for your language using your
favorite grammar notation.
====================================================================