+ 4
What does DRY mean to Programmers???
Programming Terms
8 Antworten
+ 14
Don't repeat yourself.
https://medium.com/@Ialimijoro/the-dry-principle-and-why-you-should-use-it-f02435ae9449
+ 6
Repeating a code is quite problematic. Here's why
- We ll have to write more code obviously, but this is not the main problem.
- Main problem is maintaining those codes. Suppose we have to make some change then we ll have to apply that change on all the repeated places. It's a big headache. That's why programmers sometimes goes to great lengths to keep it DRY using various complicated design patterns.
I have a simple example here to demonstrate the benefits of keeping it DRY.
In this code we can clearly see DRY is missing and same function is repeated, hence the long code & painful future efforts to add colour.
https://code.sololearn.com/WFc1NNwxG2q8/?ref=app
But a refactoring attempt with DRY in mind can greatly reduce the effort ( future efforts too).
https://code.sololearn.com/WJPh1bqz0VFd/?ref=app
Ending Notes:
Although writing DRY codes might look easy but it ll come with practice , study, knowledge of language & design patterns.
DRY principle is applicable to all programming languages
+ 4
Even the simple use of functions/methods is an example of DRY I believe.
+ 2
It's for all languages
0
not wet
- 1
Don't repeat yourself: used to help programmers save on memory by not writing the same code over and over