Behavioral patterns

Visitor

Add new operations to a set of object types WITHOUT editing those types, by moving each operation into a visitor and letting elements "accept" it. An animated lesson where the diagram draws itself as the design grows.

  • Lesson 10 of 10
  • Animated diagrams

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

10 lessons, each with diagrams that draw themselves.

What you will learn

  • The problem: operations spread across every class
  • A real-world analogy: the tax auditor
  • How it works
  • Double dispatch, the engine
  • The trade-off
  • When to use it / when to avoid

More low-level design

Watch Visitor take shape

Sign in and the lesson opens with its diagram ready to play, and the rest of Behavioral patterns beside it.

DSA comes with the all labs plan and every ChaiCode batch.