Learning

What-If Cases

Share a Status, Not Every Sentence

Share status meaning while keeping audience wording independent.

Downloads

A participant page and an audit export both describe confirmation delivery. They share the meaning of Pending and Delivered. Their wording serves different readers.

The product owner asks for two changes: make the participant's pending message friendlier, and add a new official delivery state, Cancelled.

Change Participant Wording Audit Representation Shared Status Model
Friendlier pending message Changes Should stay stable unless separately requested Same meaning
New official Cancelled state Must account for it Must account for it Changes

Work out the intended reach before choosing a helper. Reusing the status definition does not require one shared display sentence.

Engineering Depth

A shared model can express the common meaning:

enum DeliveryState { Pending, Delivered }

Separate presentation functions can then serve their own readers:

fn audit_label(state: DeliveryState) -> &'static str {
    match state {
        DeliveryState::Pending => "pending",
        DeliveryState::Delivered => "delivered",
    }
}

The participant function can use a friendlier sentence. Changing that sentence need not alter this export. Adding Cancelled to the enum makes exhaustive consumers revisit the new case; it does not tell them which wording their owner wants.

Compare a common display(state, audience_flag) helper: it now owns two audiences' wording decisions. That may be a deliberate contract, but saving a few identical lines does not establish that shared authority.

Your Reflection

The audit consumer promises stable machine-readable labels. A UI refactor renames Pending to “Almost there.” What should remain unchanged, and what would you review before adding Cancelled?

Worked Discussion

Keep the existing export label unless its compatibility contract is deliberately changed. For Cancelled, establish the new state's meaning and owner, then update each affected consumer truthfully. A compile error can expose an unhandled variant; it cannot supply the state definition or approve a wire-format change.

Navigation