Protocol Traces and Pattern Composition
What this concept is
A behavior contract includes histories: calls, returned values, state, exceptions, effects, ordering and forbidden actions. Patterns partition responsibilities; they do not compose guarantees automatically. Test the interaction where one pattern's output becomes another's input.
Why it matters here
A Command may pass a State guard, update local state and then notify Observers. If notification fails, should the command return failure, partial success or an accepted result with delivery failures? Retrying the entire command can duplicate effects. A diagram cannot answer this policy question.
Concrete example
Model publish approval as: validate expected state -> compute transition -> record accepted local result -> notify views. If the view throws, retain the accepted transition and return a separate notification failure. Replaying accepted records should rebuild state without sending the notification again.
For a different contract requiring all changes to be atomic, this sequence is insufficient. You would need a suitable transaction boundary or a redesign that makes the pending/failed delivery explicit. The offline project deliberately chooses local state authority and reports observer errors separately.
Write a trace with columns step, public state, history length, callback order, return/error, and recovery. Include actions that must not occur: no second policy invocation, no next-page fetch, no later handler after a terminal decision.
Common confusion / misconception
Coverage of every method once misses sequence defects. A generated finite sequence suite is also not a proof about arbitrary histories. Mutation checks demonstrate sensitivity to specific mistakes, not universal correctness. Test structure-independent observations rather than asserting private class names.
How to use it
Build an independent model with a different representation: one version list and cursor for undo stacks, a matrix for State classes, and arithmetic for Visitor. Enumerate a small domain, then inject failures and changed assumptions. Keep the oracle independent of the implementation's tables and helper functions.
Check yourself
Why can copying the production transition table into a test miss a wrong cell? Which observations distinguish a correct snapshot observer from a live-list one? How do you label an external outcome after acknowledgement loss?
Mini drill or application
Complete experiment E3 and the project. Compose workflow plus subject; inject one observer failure after an accepted transition. Preserve state and accepted records, report the failure, and replay without re-notification. Defend the chosen ordering against an alternative, using one concrete counterexample.
Read this only if stuck
GoF book index for collaborations; the module's contracts and guided labs supply the actual executable scope.