🎓 A1Learner
🔍
0 of 47 lessons completed

Trade-Offs and Wrap-Up

A trade-off is a choice that gains one thing and loses another. Every design choice carries at least one trade-off, and naming the trade-off is part of the design work.

Copies cost storage

Storing 100 photos at 2 MB each takes 200 MB with one copy. Three copies take 600 MB and protect against a lost copy.

photos = 100
size_mb = 2
one_copy = photos * size_mb
three_copies = one_copy * 3
print("photos:", photos)
print("one copy:", one_copy, "MB")
print("three copies:", three_copies, "MB")

Capacity costs money-like units

A bigger server handles more requests each second. The bigger server also costs more for every month it runs.

small = ("small server", 10, 50)
bigger = ("bigger server", 25, 120)
plans = [small, bigger]
for name, capacity, cost in plans:
    print(f"{name}: handles {capacity} requests per second, costs {cost} units a month")

A wrap-up covers three jobs

A good wrap-up restates the design in plain words. The same wrap-up names the weakest part and the next improvement.

wrap_up = [
    ("restate", "three copies keep the photos safe"),
    ("weakest part", "the single app server does all the work"),
    ("more time", "a second app server would share the work"),
]
for label, line in wrap_up:
    print(f"{label}: {line}")
print("sections:", len(wrap_up))

Example

photos = 100
size_mb = 2
copies = 3
one_copy = photos * size_mb
total = one_copy * copies
print("photos:", photos)
print("size each:", size_mb, "MB")
print("one copy:", one_copy, "MB")
print("three copies:", total, "MB")

Key points

  • Trade-off: every choice buys something and costs something else.
  • Copies: extra copies protect stored data and raise the storage the system uses.
  • Wrap-up: a closing summary that restates the design in a few lines.
  • Weakest part: the part most likely to break or run out of room as the system grows.

In this example, three copies raise the storage from 200 MB to 600 MB, and the wrap-up habit is to name that cost instead of hiding it.

Note

A wrap-up also says what more time would add, and a trade-off with no cost named is only half stated.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

A design keeps three copies of every photo. What is the trade-off?