Version 0 of Design patterns in Tcl

Updated 2001-10-09 16:56:47

Richard Suchenwirth - Design patterns have been made famous by the book "Design Patterns. Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (The Gang of Four). A short list of the 23 patterns in that book is at http://wiki.cs.uiuc.edu/PatternStories/DesignPatterns

Most patterns assume OO approaches, inheritance, etc., and thus are more suited for Incr Tcl design patterns. But some can be done in pure Tcl, or are used in the Tcl implementation. Let's brainstorm...

  • Chain of responsibility: We can have that effect with
 rename existingName _otherName
 proc existingName {...} {
    # do the special stuff, eventually:
    _otherName
 }
  • Flyweight: Re-use of small objects from a pool, so distinct objects are only created once, and referred to later. Used since 8.4 in the C implementation of split $string ""