DEV Community

khalil la
khalil la

Posted on

DRY or not DRY?

What is DRY?

DRY (Don't repeat yourself) is a principle of software development aimed at reducing repetition of code.

How to Achieve DRY?

To avoid redundancy, DRY recommand replacing repetition with abstractions or using data normalization.

What is DRY Benefits?

Expectations

Less lines of code is less amount of bugs. It also saves time and effort and is easy to maintain.

Reality

"Duplication is far cheaper than the wrong abstraction." - Sandi Metz.
DRY at any cost isn't the right solution. Be aware of wrong code reuse. It's lead to a system too hard to maintain.

Thanks for reading

Top comments (0)