3 ms·
Anecdotal but I've found it much easier to start DRY and then later duplicate code that diverges a little bit from the original. What is hard is working with a
by poikroequ 2y ago
Anecdotal but I've found it much easier to start DRY and then later duplicate code that diverges a little bit from the original. What is hard is working with a large code base with lots of duplicate code. When you need to change one thing, but there's multiple places you need to make that one change, I've found it very difficult to track down all the places which need to be changed.
When you can't DRY, or when it's simply not practical, at least try to find a way of keeping track of duplicate code. Using enums and global constants can help you by finding all the references to those symbols and locate all the places in your code which need to be updated or refactored.