Gof Visitor

Visitor in modern Java: adding operations over a stable set of element types without editing them, and how a sealed hierarchy with an exhaustive switch competes with the classical double-dispatch version. Covers the expression problem—new operations cheap versus new element types cheap — the cases where classical Visitor still wins (types you do not compile, libraries whose API is accept()), stateful visitors that are unsafe to share, recursion depth on deep structures, and unknown element types from a newer producer. Use when several operations must run over one object structure, when instanceof chains grow over a closed hierarchy, when adding an operation means editing every element class, or when an accept/visit pair is proposed. Does not cover the structure being traversed (gof-composite), traversal protocols (gof-iterator), sealed hierarchy design (java-composition-over-inheritance), or value semantics (java-immutability).

robsonkades Updated

File contents

robsonkades/agent-skills/tree/main/skills/gof-visitor commit 23447dae79

Frequently asked questions

npx skillmds@latest add robsonkades/gof-visitor