The Composite pattern is used when you want to treat groups of items the same way you do individual items. This is done by using the same interface for both groups of items and individual items. One example is that often you want to treat groups of files or directories the same way you want to treat individual files. i.e. you may want to copy(), encode(), zip(), delete(), rename(),... This way your code doesn't need to know if it is dealing with many files or one.
I just created an ArrayFilter. It allows you to query arrays much like SQL allows you to query database tables. I used the composite pattern to implement the where clause conditionals. Whether you have one or many all conditinals must evaluate to true or false.
For example "select * from array where col1='jones'" is one conditional, but by using the composite pattern I had to code very little to do much more complex logic like "select * from array where col1='jones' && col2='john' || col1='smith'". The code is available via my website
http://www.fdsapi.com Another example would be to treat a group of gui controls in a similar way to one. You may draw() a button or draw() a window, where the window contains buttons, listboxes, etc that all have draw() methods. One powerful thing about composites is that because they have the same interface as the individual items that they contain, they can also contain other composites. In this example it would mean windows could contain other windows as well as simple controls.