Learn

Architecture & pattern guides

Read the idea, build it on a Grid, prove it in a challenge. Short, practical guides — illustrated with RodGrid's own nodes — on system design, design patterns, flow modeling, and how to get the most out of the app.

All articles

Pattern building blocks (generic roles)

The Generic Roles section of the pattern palette: Actor, Service, Handler, Event and twelve more neutral participants for sketching any pattern by who does what, each renamed for the job it plays.

To sketch a design pattern by who does what, without committing to a pattern-specific node or a technology, use the Generic Roles section. On a Grid made for design patterns it is the first section of the palette's Design Patterns group, it opens by default, and it is free on every plan. In a pattern Challenge, you get the roles that Challenge's brief allows.

The Generic Roles section of the palette (free on every plan).

What each role stands for

Participants that act:

  • Actor: an external user or system.
  • Client: the participant that requests work from the system.
  • Component: a generic participant, when no more specific role fits.
  • Module: a cohesive unit of related parts.
  • Service: a provider of behaviour that others call.
  • Handler: the participant that processes a request.
  • Coordinator: orchestrates other collaborators.
  • Publisher / Subject: emits notifications or events.

What passes between them, and the contracts they agree on:

  • Port / Interface: an abstract contract, the same node the Hexagonal (Ports & Adapters) and Microkernel / Plugin articles use for one.
  • Event: something that happened.
  • Message: data passed between roles.
  • Queue: a buffered channel for messages.

What they rely on:

  • Data Store: generic persistence.
  • Cache: a fast store consulted before a slower one.
  • External System: a collaborator outside the design.
  • Scheduler / Timer: a trigger based on time.

Sketching a known pattern

Here is Observer sketched for a thermostat that two parts of a heating system react to:

  1. Place one role per participant: a Publisher / Subject for the thermostat, whose state changes, and a Handler for each part that reacts. Drag a role onto the Grid, or double-click it in the palette.
  2. Rename each node for its job: double-click it and type "Thermostat", "Boiler control", "Wall display". Until you do, the card shows the role's name.
  3. Draw the relationships and label each edge with a verb that says which way it works, here "notifies" from the thermostat to each handler. Names and verbs together state the intent: the thermostat changes, and the others react.
Observer, in generic roles
Watch outThe sketch shows Observer's shape, not its rules, which are in Observer. If you leave the nodes under their palette names, a diagram of a Publisher / Subject and two Handlers looks like a dozen other designs, and a reader has a hard time telling which pattern it models or what each part does.

Generic role or pattern-specific node

The other sections of the Design Patterns group hold pattern-specific participants, such as Observer and Strategy in Behavioral (GoF). When the palette has a node for the participant you mean, it says more than a renamed Handler. Generic roles are for a participant the palette has no node for, for a pattern you cannot name yet, and for the supporting cast: the store, the queue, the timer. Strategy, Factory Method and Adapter explain three of those named patterns.

Practice: filling in Strategy with generic roles

Open the Strategy Pattern Challenge, which allows six nodes. The palette there has a Strategy node for the concrete strategies, but no node for the context or the contract they share, so you draw those two with generic roles: a Component for the context, say "Route planner", and a Port / Interface for the contract, "Travel time". Add two Strategy nodes, "Walking" and "Driving". Rename every node, draw an edge labelled "uses" from the context to the interface rather than to the concrete strategies, and an edge labelled "implements" from each strategy to the interface. Then read it aloud: "Route planner uses Travel time; Walking and Driving implement it." If any part of the sentence still comes out as "Component" or "Port / Interface", that node still needs its name.

Practice this