Decorator Pattern Lecture Oo29 Artificial Life Simulation
Teaching Points n Decorator Pattern n Artificial Life Simulation –Lab 3
Review n What is a component n How can you use components and interfaces to efficiently partition your system’s physical architecture? n In Java-style exception handling what is “thrown?”
Decorator Pattern n The Problem –sometimes we want to add responsibilities to individual objects, not to an entire class. –for responsibilities that can be add/withdrawn dynamically –when extension by subclassing is impractical
Decorator Pattern n The solution –Attach additional responsibilities to an object dynamically. –A flexible approach is to enclose the component in another object that adds the responsibility.
Decorator Pattern (structure)
Decorator Pattern (example)
Artificial Life Simulator n A framework n Pattern based –Decorator –Chain of responsibility –Observer –Iterator
Use Case Diagram
Architecture
Run Simulation Use Case
Update Creature State Use Case –Interaction with the world
Update Creature State Use Case n Reproduction
Teaching Points n Decorator Pattern n Artificial Life Simulation –Lab 3