DEV Community

Jonathan Hall
Jonathan Hall

Posted on • Originally published at jhall.io on

1

Staying DRY in a WET codebase

There’s an often uncomfortable tension between DRY and WET code. For all its merit, DRY can also be problematic.

But sometimes, WET is just a really, really bad idea. Usually when it means duplicating business logic. By having that logic live in two or more places, we greatly increase the chances of bugs creeping in when only one instance is updated.

Is there any way to balance these concerns?

One approach is to WET your code—that is, duplicate the business logic in two or more places—but then have an automated test ensure that the different implementations always produce the same results.

This approach is used in some fairly prominent code bases, including the Go standard library, where the cost of an additional dependency is high, but implementations must remain consistent.


If you enjoyed this message, subscribe to The Daily Commit to get future messages to your inbox.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs