Composite Design Pattern

  • 640 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
640
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
18
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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. Composite Objects
    • Objects that contain other objects
    • It compose objects into tree structures to represent part-whole hierarchies.
    • Example:
    • A drawing may be composed of graphic primitives, such as lines, circles, rectangles, text, and so on.
  • 3. Problems Resolved
    • It lets clients treat individual objects and compositions of objects uniformly.
    • We often must manipulate composites exactly the same way we manipulate primitive objects.
  • 4. Sample Code (Composite method)
    • 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(); } }