3 ms·
If you have the same code copied to several places it makes it much harder to maintain. If there you find a bug in that code block then you have to fix it in se
by drKarl 4y ago
If you have the same code copied to several places it makes it much harder to maintain. If there you find a bug in that code block then you have to fix it in several other places, and if you forget some, a bug that you thought you had already fixed might arise again.
- ozim 4y agoHow often do you really write the same piece of business logic code in multiple places? I think discussion is that mostly it really is different code that only superficially looks the same. I don't like pizza example. But I have seen more issues because people were trying to cram code that looks the same in one function than some bug needed to be fixed multiple times because code was duplicated. You also have layers of code and DRY best applies to things like "SaveStuffToDatabase" or framework code. Where a lot of business code can still be better off duplicated because usage will evolve in different ways like: CreateNew vs EditExisting - there is a lot of business cases where when creating new entity you want to set some values that should never be available in Editing - but saving to database should be just saving to database...
- kitkat_new 4y ago> How often do you really write the same piece of business logic code in multiple places? well, depends if you avoid DRY or not. If you apply DRY, zero times.
- ozim 4y agoThink again. Read with understanding. What is really the question that is asked?