Skip to main content

Simple Design Emerges Through Cleanup

What this concept is

Simple design is not what appears magically in the first draft. It emerges as you keep tests green, remove duplication, improve expressiveness, and resist needless complexity.

Why it matters here

Learners often think they must design the perfect structure upfront. This chapter corrects that. Good structure often appears because you keep cleaning what the code is already telling you.

Concrete example

You notice two functions both update image, dispose the old value, and replace it. Extracting replace_image(new_image) removes duplication. That tiny move often reveals a stronger abstraction and may even suggest a better class boundary.

Common confusion / misconception

Simple design is not "fewest classes possible" or "avoid abstraction." It is pragmatic. Remove duplication, make the code say what it means, and keep the design just strong enough for current needs.

How to use it

When code starts to feel heavy, ask:

  • What is duplicated here?
  • What name would make this easier to explain?
  • What responsibility is leaking across boundaries?
  • What abstraction is real, and what abstraction is premature?

Use tests to support the cleanup.

Check yourself

Why is duplication often the earliest visible sign that a better design wants to emerge?

Mini drill or application

Find one repeated code pattern in your project. Refactor it into a named helper or shared abstraction. Write one sentence explaining what design improvement the extraction exposed.

Read this only if stuck