lecture11_observer.pdf - CSC3380 Object Oriented Design Lecture 11 Observer Quiz answer Pattern Strategy Strategy vs State • Similar diagrams easy to

lecture11_observer.pdf - CSC3380 Object Oriented Design...

This preview shows page 1 - 9 out of 37 pages.

CSC3380 Object Oriented Design Lecture 11: Observer
Image of page 1
Quiz answer Pattern: Strategy
Image of page 2
Strategy vs. State Similar diagrams, easy to confuse. Strategies: Created outside the object. Given to it with constructor or as a function parameter. (the latter is in the scavenger hunt) Handle a single, specific thing (like grasping or navigation) Can be multiple strategies simultaneously in one object. Usually don’t change while the object is live. States: Handle everything an object does. Sometimes hold a reference to their context. Often the state is responsible for changing to a new state or returning one. Generally only one.
Image of page 3
Image of page 4
This class Observer pattern Event-driven programming
Image of page 5
Procedural programming (without events) Program starts in “main” (or at the beginning of the script) Create objects, call methods. Methods call other methods. Eventually, all methods return, main exits.
Image of page 6
Event-driven programming (AKA publish/ subscribe) Wait Wait for something to happen (poll events). Register Register event handlers. Define Define events. Create Create objects.
Image of page 7
What are events? AKA signals, triggers Events are objects which represent an important occurrence Objects are polled .
Image of page 8
Image of page 9

You've reached the end of your free preview.

Want to read all 37 pages?

  • Spring '09
  • Suptik