Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    Cheat sheets: all cheat sheets

    Observer or Mediator? Design Decisions Workbook

    Free two-page PDF with six original open-ended design scenarios and reasoned answers, plus a link to an 8-question online lesson practice on Observer, Mediator and related patterns.

    observer-mediator-design-decisions-workbook.pdf2 pages · 6 KB
    Every page, in this page.

    Practice the design decision

    Use this two-page workbook to separate independent notifications from coordinated workflows. Answer six original scenarios before reading the worked solutions.

    • Identify who owns the business invariant.
    • State ordering, subscription lifetime and failure behavior.
    • Explain how duplicate delivery is handled.
    • Prefer a direct call when indirection adds no value.

    What you will learn

    Observer supports independent subscribers; a mediator-style coordinator makes collaboration rules explicit. Neither name guarantees durable delivery, transactions or successful retries. The workbook includes practical checks for unsubscribe behavior and duplicate-safe effects.

    The .NET interface and lifecycle discussion is grounded in Microsoft Learn: Observer design pattern and Observer best practices. The exercises and architectural trade-offs are original.

    No code execution is required for these design-reasoning exercises.

    Sample scenario

    A chart and a status panel independently observe temperature readings. A new requirement says billing must happen only after a reading is durably recorded. Should billing become a third subscriber whose handler happens to be registered last?

    Worked answer: No. Subscriber registration order is a fragile place to encode a required dependency. Keep independent presentation updates as notifications. Give persistence-before-billing an explicit workflow owner, define what happens after persistence succeeds but billing times out, and identify the same logical operation during retries.

    Observer or Mediator does not itself provide durable delivery or cross-system transactions. A direct application-service method can be enough for a small fixed workflow. Before downloading, write one subscription-lifetime test and one duplicate-request test; compare your reasoning with the six scenarios and solutions in the PDF.

    Companion practice

    The downloadable PDF retains its six open-ended scenarios and worked answers. For timed multiple-choice practice on the same decisions, take the 8-question Observer, Mediator, Chain of Responsibility and Visitor lesson practice from Design Patterns in C# (15 minutes, Full Access). It reviews the same concepts; it is not a copy of the PDF scenarios.

    Quick decision sheet

    • Observer: independent reactions to a fact; name the payload contract and the owner of each subscription.
    • Mediator: explicit interaction rules; name the invariant, next step and recovery owner.
    • Ordering: required dependencies belong in visible control flow, not incidental subscriber registration.
    • Failure: a definite decline and an ambiguous timeout need different responses.
    • Delivery: distinguish latest-only presentation from retain-every-sample auditing.
    • Duplicate effects: preserve logical operation identity and define atomic claims, payload conflicts and retention.
    • Recovery: durable progress and compensation may be needed; a local transaction cannot roll back arbitrary external calls.

    Think of a notice service with independent subscribers versus a booking desk coordinating specialists. This analogy describes responsibility only; neither guarantees asynchronous execution, durability or exactly-once effects.

    Video companions

    Dev Leader (Nick Cosentino) provides Observer with System.Reactive and a C# chat mediator walkthrough, both from 2023. Use them for mechanics and communication roles, then apply the workbook's failure and lifetime questions. They do not implement this booking workflow's durable recovery or establish a current .NET/package baseline.

    TechInterviewNotes Editorial Team · Updated 7 Oct 2026 ·