When DRY Doesn’t Work, Go WET

I’ve seen this mistake many times, and I’ve made it myself. When you first read about the DRY programming concept, you probably misunderstood it.

What was going on in your head was this:

Wikipedia: DRY stands for not repeating the same code twice.

You: Hmm, ok I’ll replace all my duplications with abstraction.

And it seems like a good solution, but it’s not. Your abstraction is often wrong.

Here is why:

  1. You see duplication.
  2. You extract duplication into a new abstraction (method, class).
  3. You replace the duplication with the new abstraction.
  4. You think your code is perfect.
  5. Time passes.
  6. The product manager has new requirements. Your abstraction is almost perfect for them.
  7. You start to implement the new requirements.
  8. And here’s the little but:
  9. Your abstraction is almost perfect. Why? The new requirements affect only 95% of the old code you extracted into abstraction. The other 5% is not affected. And instead of creating a new abstraction with 95% copied code from the current one, you decide to change the code of your abstraction.
  10. You add a conditional statement, if..else for example, and pass a parameter, so your abstraction can perform different actions for different decisions.
  11. Now your abstraction behaves differently for different cases.
  12. Another new requirement arrives. Another additional parameter. Another new conditional. (Loop until code becomes very difficult to understand and maintain.)
  13. Congrats, you’ve created a wrong abstraction.

The code no longer represents a single, common abstraction. It becomes a condition-laden procedure. It’s hard to understand and easy to break. Adding new features is incredibly hard and every new feature complicates the code even more.

It’s an infinite loop.

So what to do?

Write Everything Twice.

#python #software-development #javascript #programming #mobile-development

What is GEEK

Buddha Community

When DRY Doesn’t Work, Go WET

tu locker

1635748246

Sự hiện diện của giải pháp Smart Locker, như một nâng tầm dịch vụ, sẽ giúp khách hàng chứa đựng tư trang trước khi thoải mái tận hưởng thời gian mua sắm.

#tủ_locker #tủ_sắt_locker   #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên

Website: 

locker

tủ sắt nhiều ngăn

tủ đựng đồ nhân viên

tủ locker

tủ sắt locker


 

Smart Locker

APROP đã tin tưởng chọn Smart Locker là đơn vị đồng hành trong việc triển khai lắp đặt hệ thống Smart Locker Wireless với công nghệ hiện đại để phục vụ việc gửi/ nhận hồ sơ cho văn phòng.

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên

Website: 

tủ locker

tủ locker

tủ sắt locker

locker

tu sat locker


 

lcoekr

Tủ thông minh giúp tăng đáng kể thời gian lao động cá nhân và đơn giản khâu vận hành. Công nghệ điện tử và điện thoại thông minh được sử dụng nhằm hạn chế lãng phí nguồn lực. 

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên

Website: 

ilocker

tu locker sat

tủ locker giá rẻ

tu locker gia re

tủ cá nhân locker


 

lcoekr

Tủ locker ABS N2 khối gồm có 100 ngăn đều nhau, cánh sắt mở sử dụng khóa chắc chắn, tay nắm và có thêm tấm chia ngăn, trên mỗi cánh cửa được dập 1 vị trí bảng tên và 1 lỗ thông gió

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên

Website: 

ilocker

locker

tu sat locker

tu locker

tủ locker sắt


 

locker

Tủ thông minh giúp tăng đáng kể thời gian lao động cá nhân và đơn giản khâu vận hành. Công nghệ điện tử và điện thoại thông minh được sử dụng nhằm hạn chế lãng phí nguồn lực. 

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên

Website: 

ilocker

tu locker sat

tủ locker giá rẻ

tu locker gia re

tủ cá nhân locker