Composite Design Pattern

985 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
985
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Composite Design Pattern

  1. 1. Composite Design Pattern by: Dela Cruz, Evangelista, Felisco, Jumawan REFERENCE: http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html
  2. 2. Composite Objects <ul><li>Objects that contain other objects </li></ul><ul><li>It compose objects into tree structures to represent part-whole hierarchies. </li></ul><ul><li>Example: </li></ul><ul><li>A drawing may be composed of graphic primitives, such as lines, circles, rectangles, text, and so on. </li></ul>
  3. 3. Problems Resolved <ul><li>It lets clients treat individual objects and compositions of objects uniformly. </li></ul><ul><li>We often must manipulate composites exactly the same way we manipulate primitive objects. </li></ul>
  4. 4. Sample Code (Composite method) <ul><li>public void draw() { // Iterate over the components for(int i=0; i < getComponentCount(); ++i) { // Obtain a reference to the component and invoke its draw method Component component = getComponent(i); component.draw(); } } </li></ul>

×