Chapter 11: Design

Separating things only helps if the separate pieces hide something. That act of hiding has a name, and it is where most design goes right or wrong.

Abstraction

A simpler way to think about something complicated, leaving out what you don't need right now. save(user) lets you forget about disks and SQL. Every well-named function is a small abstraction.

A good one saves an agent reading: it needs the interface and not the inside, which keeps its context small. But agents create them for almost nothing, and a wrong one costs more than none, because everything then has to bend around it.

Say it to your agent

“Add an abstraction here only if it lets callers forget something. Write out what a caller no longer needs to know. If the honest answer is nothing, delete the wrapper and call the library directly.”

The workshop

Name a word, or describe what you mean in everyday language.