Skip to main content

CSC 321.01, Class 21: Wrapup


  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • A bit more on patterns
  • Objects in Scheme
  • The subject matter of this course.
  • Evaluations.


News and Notes

  • Happy last day of class!

Upcoming work

  • Revised HW9: Document a Design Pattern due before spring break.
    • Make sure you have the problem, bad solutions, the pattern-based solution, and examples.


A bit more on patterns

The problems these patterns address

Factory How to create objects on the fly from one of many subclasses with the decision made at run time rather than compile time? Example: A video game needs to spawn monsters and the monsters change over time (different levels, etc.).

Observer We work in a world in which there is a subject and one or more observers. The observers need to know when the subject changes. MVC: If the model changes, the view should change. (E.g., Facebook)

Proxy You have an object that is expensive to create. You should only create the object when it’s really needed by the client. Or you want to enforce preconditions. The client still needs something to refer to, even thought it may not be completely needed.

Strategy Different algorithms can be appropriate for the same problem. For example, if we have a small list, we might use insertion sort and if we have a long list, we might use merge sort. The algorithm needs to be decided at run time, not compile time.

Template Method. You have multiple algorithms and you’d like to factor out the similarity in the algorithms. Or You have one algorithm, but you can make it behave differently using other functions as input. (E.g., sort in Scheme can behave differently depending on the comparator you give it.)

How the patterns address the problem





Template Method

Objects in Scheme

The subject matter of this course