WorkspaceLow-Level Design
← Course overview

Course navigation

On this page

Low-Level Design / Design Principles

foundation · 12 MIN READ

YAGNI

You Aren’t Gonna Need It asks for evidence before adding speculative capabilities. Defer uncertain extensions while keeping a clear boundary that can support a real future requirement.

Reading completion is independent of quizzes and challenges.

What you’ll understand

  • You Aren’t Gonna Need It asks for evidence before adding speculative capabilities. Defer uncertain extensions while keeping a clear boundary that can support a real future requirement.
  • Implement the supported domestic quote and return unsupported for other destinations.
  • Evaluate the tradeoff: Deferring features saves complexity, but it does not justify ignoring known requirements. Document unsupported behavior so callers can make a decision.

Useful first: Classes and Objects

The idea and when to recognize it

You Aren’t Gonna Need It asks for evidence before adding speculative capabilities. Defer uncertain extensions while keeping a clear boundary that can support a real future requirement.

  • Requirement: A shipping application only supports domestic destinations in its current contract.
  • Change to anticipate: Reject unsupported countries explicitly instead of pretending an unfinished international path already works.
  • Design goal: Implement the supported domestic quote and return unsupported for other destinations.

Start with the concrete problem

A shipping application only supports domestic destinations in its current contract.

Reject unsupported countries explicitly instead of pretending an unfinished international path already works.

Direct implementationRevised design
Returning a domestic estimate for every country creates a misleading feature rather than a useful extension point.Implement the supported domestic quote and return unsupported for other destinations.
The baseline case can hide the problem. Compare the extension and boundary fixtures before accepting this design.Deferring features saves complexity, but it does not justify ignoring known requirements. Document unsupported behavior so callers can make a decision.

Responsibilities and contracts

Implement the supported domestic quote and return unsupported for other destinations.

  • QuoteService: Implements the supported market. Public operations: quote(country)
  • MarketPolicy: Defines available destinations. Public operations: domestic

Read the design

Select a participant to inspect its responsibility and public operations. Follow the labeled relationships; an arrow indicates direction, while the legend distinguishes ownership, substitution, and temporary use.

Preparing the design walkthrough…

Follow the interaction

Choose a supplied workload and compare the direct and revised implementations. Step through the same operation in both languages. Object values are recorded after each highlighted statement; previous steps remain unchanged.

Preparing the design walkthrough…

Implementation and expected output

Read the complete example alongside its input and expected output. The implementation selector changes the displayed program; the language selector preserves your current scenario and playback position.

Preparing the design walkthrough…

Try the idea in another setting

A local notes application can retain a storage interface without shipping speculative cloud synchronization.

  • Name the new client contract before adapting the example.
  • Identify which state belongs to each object and who controls its lifetime.
  • Write one normal case and one boundary case before extending the design.

Tradeoffs and interview takeaways

Deferring features saves complexity, but it does not justify ignoring known requirements. Document unsupported behavior so callers can make a decision.

Common mistake: Returning a domestic estimate for every country creates a misleading feature rather than a useful extension point.

  • Explain the choice: Implement the supported domestic quote and return unsupported for other destinations.
  • Challenge your choice: Deferring features saves complexity, but it does not justify ignoring known requirements. Document unsupported behavior so callers can make a decision.
  • Describe a requirement that would make the simpler implementation sufficient.

Design challenge and knowledge check

Preparing the design walkthrough…

Make it your own

Saved on this device · 0/20,000

Reading completion is independent of quizzes and challenges.