composite Design Pattern helps the developer to abstract a information tree structure in code. The following example shows how to use in a Hierarchical Filter need. This page is in a continuous writing mode, check later for new updates or ask me on my twitter.
The main idea here is to present how to use it, if you want a background on composite patter I recommend Gamma et al. book. The diagram to present the composite is the follow, for this diagram I use OPM (Object Process Methodology) which shows a Hierarchical Flow process containing multiple Filters subprocesses which is invoked by it.
Figure 1 – Composite design pattern
The implementation requires two steps the pattern coding, the controller coding for filter and flow loading.
<Next writing topic>
Jumping to controller implementation. The controller will load the composite classes according to database configurations. As first step the configuration of the composite hierarchy is needed, the suggestion here is to keep the configuration inside the database as a entity relationship model. Database tables will provide the model for further view(e.g. JSON) implementation. The following diagram show how use a composite within conjunction with traditional database implementation.
Figure 2 – Business Controller in conjunction with Composite Pattern
The configuring process can be implemented using database as datasource which will store all composite information.
Ultima atualização: 20/Set/2015