AlgoViz

DRY

easy 40 min

Don't repeat yourself: every piece of knowledge has one home, and everything else asks that home.

Watch lesson4:18

Where it shows up

The same pattern appears across everyday software.

  • Ruby on Rails

    The Rails guide names Don't Repeat Yourself as one of its two guiding principles, beside Convention over Configuration.

  • Django

    Its design philosophies say that every distinct concept or piece of data should live in one place. A model class drives the table, the forms and the admin pages.

  • Protocol Buffers

    One `.proto` file describes a message, and the compiler writes the classes for many languages. The shape has one home.

  • CSS custom properties

    MDN explains that a value is defined in one place and referenced in many. Design tokens such as `--main-text-color` build on this.

  • Terraform modules

    HashiCorp advises to write reusable modules when several deployments have similar resources, such as the network of each environment.

  • GitHub Actions

    A reusable workflow is called from other workflows, so that the release steps are not pasted into each repository.

  • pytest fixtures

    Fixtures in a `conftest.py` serve a whole directory of tests. Shared set-up has one home.

  • React state

    The React documentation advises to avoid duplicated state, and to choose one component that owns each piece: a single source of truth.

  • axios instances

    An instance carries the base address, headers and timeout, so each API call states only its path.

  • Twelve-factor config

    Settings that differ between deployments live in the environment, outside the code. One loader reads them.