AlgoViz

Abstractions in system design

easy 22 min

An abstraction hides how something works behind a small, stable interface, so callers only need to know what it does.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

HIDE: Hide complexity, Interface contracts, Decouple concerns, Encapsulate state.

A light switch. The same switch works with a power pole or a solar panel, and a cloud can still dim the lamp.

Cheat sheet

Shows
what
Hides
how
Presentation
UI, controllers, endpoints
Service
business logic, use cases
Repository
data access
Infrastructure
database, cache, external services
Links
c x m becomes c + m
Leaks
time, failure, limits, consistency

Spot it when you see

  • A technology that may change.
  • The same details repeated by many callers.
  • Two teams working in parallel.
  • Tests that need a real database.

Tricks that stick

  • H is for hide, I is for interface, D is for decouple, E is for encapsulate.
  • What outside, how inside.
  • Wrap to add, inject to choose.

Do not forget

  • A god interface.
  • Storage words in the interface.
  • Pretending a remote call is local.
  • Layers that only forward.
  • Fakes that behave differently from the real thing.