XmlObject - Adaptive Object Model

Better Designs Faster

Static Object Model

Here is a simple static object model modeled in a diagram.

 

Static Object Model Graphic

Figure 1: Static Object Model

 

It models a car, with a four cylinder engine.  It is almost insultingly simple.  It shows a car with a field, named Engine.  This field has a type, i.e. Four_Cyl_Engine.  The class Four_Cyl_Engine defines four fields.  Each field is named, i.e. Cylinder1, Cylinder2. and each field has a type of Cylinder.    It is considered static because the relationship between the Car and Engine (and Engine and Cylinder) is fixed at compile time. 

This is not always bad.  In fact there are many times when a static object model is properly called for.  It often makes good sense to model things that are fixed in nature with a static object model.  A good example might be to model a person as having two eyes, two ears, and one nose and mouth.   Static object models are ideal for simple problems, problems that are well understood, and problems that are on their way to being well understood.  Static object models are almost always used for teaching programming, when the complexity of a dynamic or adaptive object model would just get in the way. 

Most every developer, even the beginner, would look at the above design and see that it could easily be improved.  It makes obvious sense to capture the number of cylinders in an array rather than individual fields.

 

Better Static Object Model

Figure 2: Better Static Object Model

 

As in the previous model, this diagram models a Car that has a field, named Engine, again of type Four_Cyl_Engine.  However, instead of individual fields for the cylinders, this model of the Engine captures the cylinders in an array.   The number of cylinders is held in a field named CylinderCount and this value would be hardcoded to the value 4.  Note that we still have a model for a car with a four cylinder engine and it is a still a static model, but one that is much simpler.

XmlObject Graphic