DEV Community

Discussion on: Stop trying to be so DRY, instead Write Everything Twice (WET)

Collapse
 
juliuskoronci profile image
Igsem

I am more of an advocate of common sense. Experienced devs will write the abstraction straight away but it is never as simple as DRY or WET. If you have 2 use cases you should always think about DRY but when considering this, I try to look at a few things:

  1. How much time it takes to create the abstraction - if I need to spend a week to abstract something I can write in 10 minutes there is no point in abstracting
  2. How likely it is that I will need to reuse the logic - by likely I don't mean in my head but in actual requirements, designs etc.
  3. What are the differences between the 2 use cases and the possible 3rd one - often you find yourself stretching the Abstraction just to fit in a similar use case and that is very bad. A better approach would be then partial abstraction and abstraction composition

So don't be DRY or WET but be smart and use your common sense and experience :)

Collapse
 
paddy3118 profile image
Paddy3118

Be moist. Exactly.

Collapse
 
n13 profile image
Nik

It's not about whether it's the same logic, it's about whether it's the same thing.

If your app features a yellow submarine and a banana, you wouldn't want to abstract out the colour yellow as they're two totally different things.

Collapse
 
juliuskoronci profile image
Igsem

Well you would abstract out the color into a colors constants TBH :D