Behavioral Design Patterns

Soulbound by Bethany Adams available on Amazon

“Behavioral design patterns is basically the ways in which objects interact with each other particularly with the passing of responsibilities back and forth.”

Closing out the series introducing design patterns the guys discuss behavioral design patterns. These deal with communication between entities. They provide easy and flexible communication between objects.

Episode Breakdown

  • 10:32 Chain of Responsibility

    “One way to think about this is like a factory assembly line.”

    The chain of responsibility is a way of passing a request between a chain of objects. This pattern creates a chain of receiver objects for a request allowing you to launch and leave requests with a single pipeline with many handlers. The handlers can arbitrarily be reordered.

  • 14:52 Command

    “It’s basically just a bag of stuff you’re passing on.”

    The command pattern encapsulates a command request as an object parameterizing clients with different requests. It is basically an object oriented callback.

  • 18:04 Interpreter

    “You’ll see this in the guts of compilers…I’ve not had to use this very often.”

    Interpreters are a way to include language elements in a program to evaluate language grammar or expression. These include SQL parsing or symbol processing engines.

  • 22:59 Iterator

    “This basically the thing you use in a for loop.”

    Iterator patterns allow you to sequentially access the elements of a collection without exposing the underlying representation. Standard libraries are iterators.

  • 29:14 Mediator

    The mediator pattern defines a simple communication between classes. It reduces the complexity between multiple objects in a many-to-many relationship and allows for the individual objects to be interchangeable.

  • 31:00 Memento

    “If you’re sending a command to an object with a memento pattern you would capture the state first.”

    Use a memento pattern to capture and restore an object’s internal state. These promote undo or rollback to full object status. This is used heavily in text editors or programs where you need caching.

  • 34:50 Null Object

    “Null is not a thing, it’s not knowing a thing.”

    The null object acts as a default value of an object. Abstract classes specify operations, concrete classes, and a null object class. The are used when the object requires a collaborator or abstract null handling from the client.

  • 41:06 Observer

    “X observes Y…Y doesn’t have to know what is observing it.”

    The observer pattern is a way of notifying changes to a number of objects in a one-to-many relationship. If an object is modified the observer notifies its dependents of the modification.

  • 42:58 State

    “I used this pattern when I wrote the contact forms for our websites.”

    The state pattern alters an object’s behavior when its state is changed. In effect it creates an object-oriented state machine.

  • 45:40 Strategy

    An algorithm encapsulated in a class is a strategy pattern allowing behavior or algorithms to be changed at runtime. Objects can have various strategies, i.e. a context object’s behavior will vary depending on the strategy object.

  • 49:08 Template Method

    To defer the exact steps of an algorithm to a subclass use a template method. It creates a skeleton of an algorithm in an operation. The subclasses then may redefine some steps without changing the structure. Base classes declare an algorithm place holder then derived classes implement them.

  • 51:42 Visitor

    “I’ve used this recently with parsing Odata expressions.”

    The visitor pattern defines a new operation to a class without changing the class. This is a classic technique for recovering lost type information.

IoTease: Product

Tessel 2

A microcontroller that builds connected devices that run JavaScript, Python, or Rust. The Tessel 2 is designed to create a plug and play modular ecosystem. At its core is a Linux distro with Node.js on top of that. Each module has an open source library that can be accessed via NPM. “It’s literally plug, npm install, and play.”


  • Ports:
    • 2 Module Ports
    • 2 USB Ports
    • 1 microUSB
  • Connectivity:
    • 602.11bgn WiFi
    • Ethernet
  • Processors:
    • 580MHz MediaTek MT720n
    • 48MHz Atmel SAMD21 coprocessor
  • RAM:
    • 64 MB DDR2
    • 32 MB Flash


  • 10 Pin:
    • Accelerometer
    • Servo
    • Relay
    • Infrared
  • USB:
    • Cellular
    • MicroSD
    • Camera
    • Audio
  • Community-Created:
    • Distance
    • Color Sensor
    • Keypad/Screen
    • Lights/LED

Tricks of the Trade

These patterns are not really all that hard, it’s the language around the patterns that trips people up. The way things get expressed in scientific disciplines tends to be using specialized language that may not be easy for the uninitiated. The thing to remember is that you’ll arrive at these patterns with or without the technical jargon. Most of the jargon used is not for a difficult concept but rather a shorthand for expressing an idea to better share with another person.

Editor’s Notes:

Tagged with: , , , , , , , , , , , , , ,