Code[ish]

Whether or Not to Repeat Yourself: DRY, DAMP, or WET


Listen Later

Robert Blumen is a DevOps Engineer at Salesforce, joined by Ev Haus, Head of Technology at ZenHub. Together, they're going over a critique over several methodologies when writing code as part of a large team. First, there's DRY, which stands for Don't Repeat Yourself. It's the idea that one should avoid copy-pasting or duplicating lines of could, in favor of abstracting as much repeated functionality as possible. Then, there's DAMP, or Don't Abstract Methods Prematurely, which is somewhat in opposition to DRY. It advises teams to not create abstractions unless they are absolutely necessary. Last on the list is WET, or Write Everything Twice. This is the idea to embrace duplication whenever possible.

Ev notes that, like many programming absolutes, the success of each strategy depends entirely on the context. DRY, for example, sounds like a really good idea, until it happens everywhere. Suddenly, a chunk of code becomes difficult to reason, as a developer jumps around various method definitions to piece together a flow. DAMP often makes sense as a counterpart to DRY, because if you abstract too early in your codebase, you may find yourself overloading methods or appending arguments to handle one-off cases. DRY is typically best suited for testing environments, where an absolutely reproducible set of explicit steps is often preferable in order to quickly understand what is occurring.

No matter the strategy you use, the core tenant is to solve the problem first. Try to accomplish the goal you need to, whether that's adding a feature or squashing a bug. Don't over optimize until you've finished what you need to, and don't think too far into the future about all the possible edge cases. The rest of the balance comes with experience. Some duplication is bad, but not all of it. Figuring out the absolute perfect solution is unlikely, so you've got to put the code out into the real world to find out what works. After that, bake some flexibility into your processes to adjust hot code paths or refactor them when needed!

Links from this episode
  • ZenHub is an agile project management tool for GitHub
  • Wikipedia's definition of DRY
  • "Using DRY, WET & DAMP code" is Ev's article on different coding methodologies
  • Codewars is a website with programming puzzles and challenges
  • The Pragmatic Programmer by Dave Thomas is a popular book highlighting some of these concepts
  • DRY code, DAMP DSLs by Jay Fields and DRY vs DAMP in Unit Tests by Vladimir Khorikov are more write-ups on the subject
...more
View all episodesView all episodes
Download on the App Store

Code[ish]By Heroku from Salesforce

  • 4.7
  • 4.7
  • 4.7
  • 4.7
  • 4.7

4.7

18 ratings


More shows like Code[ish]

View all
TED Radio Hour by NPR

TED Radio Hour

22,006 Listeners

Planet Money by NPR

Planet Money

30,665 Listeners

Global News Podcast by BBC World Service

Global News Podcast

7,682 Listeners

Economist Podcasts by The Economist

Economist Podcasts

4,174 Listeners

This Week in Startups by Jason Calacanis

This Week in Startups

1,283 Listeners

Accidental Tech Podcast by Marco Arment, Casey Liss, John Siracusa

Accidental Tech Podcast

2,126 Listeners

Software Engineering Daily by Software Engineering Daily

Software Engineering Daily

624 Listeners

Science Vs by Spotify Studios

Science Vs

12,192 Listeners

The Salesforce Admins Podcast by Mike Gerholdt

The Salesforce Admins Podcast

206 Listeners

The Daily by The New York Times

The Daily

112,433 Listeners

Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

Syntax - Tasty Web Development Treats

987 Listeners

The Diary Of A CEO with Steven Bartlett by DOAC

The Diary Of A CEO with Steven Bartlett

8,410 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,000 Listeners

All-In with Chamath, Jason, Sacks & Friedberg by All-In Podcast, LLC

All-In with Chamath, Jason, Sacks & Friedberg

9,826 Listeners

Plain English with Derek Thompson by The Ringer

Plain English with Derek Thompson

2,284 Listeners