SteelReed

Search

Search posts, questions…

8. Senior Skills

Analysing trade-offs like a senior: ideality, sweet spots, coupling and separation

Context-dependent dimensions, dimensional vs alternative trade-offs, the TRIZ ideality formula for scoring options, picking a sweet spot vs resolving the trade-off, boring technology, coupling as the root of trade-offs and the separation principles (sidecar, functional core/imperative shell, CQRS), plus a framework for system design interviews.

18 Nov 20269 min readSenior

–

1. The problem

Two seniors argue for three meetings: a Redis cache or a read replica for the slow orders page. One silently prioritises latency, the other data freshness. In the end, one index and keyset pagination were enough.

2. Key idea

Like buying a car: the family agrees on what matters most before comparing models. The first job is to agree on the top 3 dimensions and their order: startups usually favour speed and cost; banks favour reliability and security.

Don't say "I chose Kafka"; say "I prioritised throughput and replay over low latency and simplicity, so Kafka": state the choice in terms of what it favours.

2.1 Scoring with ideality

Ideality = Σ Benefits / (Σ Resources + Σ Harmful effects) (from TRIZ) forces you to look at the denominator: money, people, complexity, stale data, vendor lock-in. Two lifts overloaded at rush hour: "stagger clock-in times" beats "install another lift" because its denominator is close to zero.

Approach Use when Don't use when
Sweet spot (a 60-second cache TTL) not your competitive core, near deadline, mistakes are cheap load is about to grow 10x
Resolve the trade-off (CDC-driven invalidation) a recurring bottleneck, the sacrificed dimension is what users need the team can't operate the new part yet

2.2 Coupling is the root of many trade-offs

Many trade-offs exist because two things that should be independent are bound together. Separate them and each side optimises on its own:

  • In time: feature flags; batch at night, realtime by day.
  • In space: a sidecar handles TLS, retries, metrics; separate hot and cold data.
  • Between part and whole: functional core, imperative shell.
  • By condition: CQRS, separate write and read models.

Splitting creates new trade-offs too: network hops, sync pipelines, eventual consistency. If the coupling doesn't hurt yet, keep it. Default to boring technology.

3. In Java

JAVA
// Functional core: pure, no I/O, no system clock: tested with JUnit in milliseconds
record Quote(long nights, long subtotal, long discount, long total) {}
final class Pricing {
    static Quote quote(List<Long> nightlyPrices) {
        long subtotal = nightlyPrices.stream().mapToLong(Long::longValue).sum();
        long discount = nightlyPrices.size() >= 3 ? Math.round(subtotal * 0.05) : 0;
        return new Quote(nightlyPrices.size(), subtotal, discount, subtotal - discount);
    }
}
 
// Imperative shell: thin, handles the DB, transactions, the clock; needs only a few integration tests
@Transactional
public Booking book(BookingRequest req) {
    List<Long> prices = availability.lockNightlyPrices(req.homestayId(), req.checkin(), req.checkout());
    Quote quote = Pricing.quote(prices);
    return bookings.save(Booking.from(req, quote, clock.instant()));
}

Discount logic no longer needs a database to test.

A scoring example and how to state downsides

A slow orders list page, scored 1–5:

Option Benefit Resource Harm Notes
The right index + keyset pagination 4 1 1 highest ideality if the query plan confirms it
Redis cache for the first page 3 2 3 stale data, another system, hard invalidation
Read replica 3 3 2 replication lag, machine cost
Move to Elasticsearch 5 5 4 data sync, a whole new stack
  • The numbers just force people to state their assumptions; the real value is the discussion of why Redis's harm is 3, not 1. List harms by asking "and then what?" a few times per option.
  • A template: "I chose X because we prioritise A and B; in return we accept C; if load passes N we switch to Y." Record the priority order, the chosen point and the revisit condition in an ADR.
  • Rich Hickey: programmers know the benefits of everything and the trade-offs of nothing.

4. Working with AI

Delegate to AI: listing options, drafting a scoring table, asking "and then what?" for each option.

Check the AI's table:

  • The priority order was agreed with stakeholders before scoring.
  • Every option has resource and harm columns, not just benefits.
  • The chosen option has its downsides written down and a revisit condition.

5. Exercises

Exercise 1: Score ideality

A booking service must send events to a notification service. AI proposes three options: (a) a synchronous HTTP call inside the transaction, (b) publishing to Kafka after commit, (c) an outbox table + relay, and concludes "(b) is best because it's simple with no downsides". Score them and choose.

Solution to Exercise 1
Option Benefit Resource Harm Why
(a) Synchronous HTTP 2 1 5 a slow or dead notification service breaks booking; sent then rolled back means a wrong notification
(b) Kafka after commit 4 3 3 a crash between commit and publish loses the event
(c) Outbox + relay 5 3 1 the event is written in the same transaction; needs idempotent consumers and outbox cleanup

Choose (c) if the notification matters (payment confirmation); (b) is acceptable for "nice to have" notifications. "No downsides" is a sign nobody analysed it.

Exercise 2: Apply a separation principle

A product page must (1) read extremely fast at 20,000 QPS and (2) have accurate stock when ordering. One model and one table pull the two requirements in opposite directions. How do you resolve it?

Solution to Exercise 2
  • Separate by condition: the display part (name, images, approximate stock) is served from a cache or read model, allowed to lag a few seconds.
  • The ordering part checks stock on the primary DB with a conditional update: UPDATE stock SET qty = qty - 1 WHERE sku = ? AND qty > 0.
  • Change the display too: "almost gone" when stock is low, a clear message when an order fails. Fast reads and accuracy are reconciled by not making one place do both.

Summary

  • Agree on the top 3 dimensions and their order before scoring.
  • Ideality looks at resources and harms too; near-free options often win.
  • A sweet spot is quick and cheap; resolving the trade-off is better but adds parts.
  • Splitting coupling (time, space, part–whole, CQRS) creates new trade-offs.
  • Default to boring technology; always state the downsides.

Back to: Part 1: Problem solving.

Practice interview questions on this topic

All System Design questions →All Behavioral questions →

Loading comments…