composite Design Pattern helps the developer to abstract an information tree structure in code. The following example shows how to use in a Hierarchical Filter need.
The main idea here is to present how to use it, if you want a background on composite pattern, 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 an 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 data source which will store all composite information.
Design Patterns: Elements of Reusable Object-Oriented Software
Object-Process Methodology: A Holistic Systems Paradigm
Última atualização: 20/Set/2015