Composite Model

Over the last year and a half I have been working on a Composite Model Framework.

This uses:

  • Smart Types” for model attributes (A smart type is a primitive type that knows that it has been set and changed),
  • Explicit attached “business rule objects”
  • Rules can navigate the model using xslt

Use of the composite pattern for the model makes for a very robust model component (rules can survive the addition of nodes above them in the tree).  This is very easy to self check, maps directly to requirements, has a single obvious implementation point for almost any functionality to be added.

One of the key points is that the model is responsible for holding data, validating data and performing other buisiness functions.  The model is not responsible for data persistance.

The components of the system are:

Model (M)
View (V)
Controller (C)
Data Access Layer (D)

Typically the controllers constructor has a signature of C(M,V,D).
This allows us to keep the Model independent of the database and the View.

Most business rules belong in the model – the exceptions being referential integrity and uniqueness constraints that have to be on the database.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s