🎓 A1Learner
🔍
0 of 47 lessons completed

Deep-Dive on One Part

A deep dive is a close look at one part of a design, with its data and its hard cases. The rest of the design stays at sketch level during the dive.

Count reads and writes

A small sample of one day can be counted before any guessing starts. The bigger count points at the busier path.

events = ["read", "write", "read", "read", "write", "read", "read", "read"]
reads = events.count("read")
writes = events.count("write")
print("reads:", reads)
print("writes:", writes)
print("deep dive pick:", "reads" if reads > writes else "writes")

Split the reads further

Reads split by kind show where the load inside one part sits. One kind usually carries most of the count.

reads = ["page", "page", "search", "page", "search", "page"]
page_reads = reads.count("page")
search_reads = reads.count("search")
print("page reads:", page_reads)
print("search reads:", search_reads)
print("busiest read kind:", "page" if page_reads > search_reads else "search")

One write, several steps

This small model gives each write more steps than each read. Equal counts then do unequal amounts of work.

read_steps = 1
write_steps = 3
reads = 4
writes = 4
print("read work:", reads * read_steps)
print("write work:", writes * write_steps)
print("heavier path:", "writes" if writes * write_steps > reads * read_steps else "reads")

Example

events = ["read", "read", "write", "read", "read",
          "read", "write", "read", "read", "write"]
reads = events.count("read")
writes = events.count("write")
print("reads:", reads)
print("writes:", writes)
print("events in total:", len(events))
print("deep dive pick:", "reads" if reads > writes else "writes")

Key points

  • Read: a request that asks for stored data without changing the data.
  • Write: a request that changes stored data.
  • Deep dive: a close look at one part, covering its data and its hard cases.
  • Busiest part: the part handling the most requests is a strong pick for the dive.

In this example, the sample day holds 10 events and reads form the larger share, so the reading path earns the deep dive.

Note

An interviewer may name the part for the dive, and following that pick is part of the task.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

A sample day shows far more reads than writes. Which part is the strong pick for a deep dive?