4 Design Patterns Java Structural m4 Slides 4
4 Design Patterns Java Structural m4 Slides 4
Bryan Hansen
twitter: bh5k | http://www.linkedin.com/in/hansenbryan
Concepts
▪ Components represent part or whole structure
▪ Compose objects into tree structures
▪ Individual object treated as a Composite
▪ Same operations applied on individual and
composites
▪ Examples:
▪ java.awt.Component
▪ JSF widgets
▪ RESTful service GETs
Design
Tree structured
Component
Leaf or Composite, same operations
Composite knows about child objects
Component, Leaf, Composite
UML
Everyday Example - Map
Composite Decorator
▪ Tree structure ▪ Contains another entity
▪ Leaf and Composite have same ▪ Modifies behavior (adds)
interface ▪ Doesn’t change underlying object
▪ Unity between objects
Composite Summary