🎓 A1Learner
🔍
0 of 42 lessons completed

Design Problems, One Method

Design problems are open-ended prompts that ask for the design of a whole service, with no single right answer. This course solves 7 classic problems with one method, the 6 steps from the Beginner course.

One method, in order

Every problem in this course follows the same 6 steps. The printout lists them in the order the method uses them.

steps = ["clarify", "estimate", "high-level design", "data model and API", "deep dive", "trade-offs and wrap-up"]

for i, step in enumerate(steps, 1):
    print(i, step)
print("total steps:", len(steps))

Seven problems, one method

The course covers 7 problems. Each one uses the same 6 steps, so only the problem changes.

problems = ["URL shortener", "rate limiter", "chat system", "news feed", "autocomplete", "notifications", "key-value store"]

for problem in problems:
    print(problem, "- same 6 steps")
print("total problems:", len(problems))

Clarifying starts with questions

A vague ask becomes clear through questions, not parts. The printout shows 4 opening questions for a new problem.

questions = ["What must the service do?", "What is out of scope?", "How big is the scale?", "What matters most, speed or cost?"]

for question in questions:
    print("ask:", question)
print("questions asked:", len(questions))

Example

plan = [
    ("clarify", "name what the shortener must do"),
    ("estimate", "count new links and visits a day"),
    ("high-level design", "sketch the create and visit paths"),
    ("data model and API", "store long links and their codes"),
    ("deep dive", "design how codes are generated"),
    ("trade-offs and wrap-up", "weigh speed against counting visits"),
]

for i, (step, action) in enumerate(plan, 1):
    print(i, step, "-", action)

Key points

  • Clarify: ask what the service must do and what stays out of scope.
  • Estimate: work out the scale with rough arithmetic before designing.
  • High-level design: sketch the main parts and how requests move between them.
  • Data model and API: name the stored records and the calls clients make.
  • Deep dive: work through the hardest part in detail.
  • Trade-offs and wrap-up: state what the design gives up and close clearly.

In this example, the 6 steps are applied to the URL shortener at headline level only. The lessons that follow carry out each step in full.

Note

this course applies the steps to a URL shortener, a rate limiter, a chat system, a news feed, autocomplete, notifications, and a key-value store.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What is the first step of the method?