Composite Design Pattern by example
This post explains Composite design pattern with an example. When to use ? – Use Composite pattern when you have treat a collection of objects as they were once one thing. With Composite design pattern it is very easy to simplify operations over collection data structure. It reduces complexity of the code required if you were going to handle collection as special case. How to Use? - The Composite pattern consist of Component, Leaf and Composite Classes as shown below class diagram Component – Component declares the common interface that both the single and composite nodes will implements Leaf – The leaf class represent the singular atomic data type implementing he component interface. Composite – Composite is an abstract entity which declares common functionality which are needed by concrete implementation for handling collection data. An Example - Item.java public interface Item { public double getPrice(); ...
good. all info in one place :)
ReplyDeleteIf you find any conflict then lets update the post :)
ReplyDeleteHi Yogesh.
ReplyDeleteThanks to your post I finally could load a resource stylesheet for my application: I spent more than 4 hours googling everywhere and not finding the right answer.
My mistake was that I wrote:
this.getClass().getResourceAsStream("stylesheet.xsl")
But my file was located in WEB-INF/classes.
Thanks to your post I changed to "/stylesheet.xsl" and now everything works fine.
Thanks again!
@Frederic F. MONFILS You always Welcome :)
ReplyDeleteLife saver! Saved me a couple of hours as well.
ReplyDelete