Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    Cheat sheets: all cheat sheets

    Strategy or State? Interview Workbook

    A free two-page worksheet with six design scenarios and worked answers on pricing, state transitions, rounding, concurrency and idempotency.

    strategy-state-interview-workbook.pdf2 pages · 5 KB
    Every page, in this page.

    Practise the reasoning, not just the pattern name

    Download the two-page workbook, answer the six scenarios, then compare your reasoning with the worked solutions. Topics include interchangeable pricing policies, legal order transitions, monetary precision, optimistic concurrency, simple transition tables, and duplicate-safe event handling.

    Each answer explains the invariant and the trade-off. The worksheet intentionally needs no executable code.

    Companion learning

    Study the free Strategy and State course, then try the related design-decisions mock test.

    Sample scenario

    Two requests load an order in Pending. One pays; the other cancels. Both save their preferred state. Would moving the rules into separate State classes make this race safe?

    Worked answer: No. State classes can express which transitions are legal, but they do not serialize database updates. Save with an expected version or an equivalent conditional update. One request wins; the other rereads the state and applies the rule again. Keep external payment effects idempotent and reconcile uncertain outcomes.

    Compare this with choosing a standard or loyalty price for a validated basket. That is interchangeable calculation behavior, which may suit Strategy or a simple function. The workbook asks you to justify the business invariant before choosing either pattern and supplies six reasoned answers.

    TechInterviewNotes Editorial Team · Updated 7 Oct 2026 ·