4 ms·
The way I like to work is first to write out all the code I need to make something work correctly, then I go back over the code to see if there's anything that
by Osiris 6y ago
The way I like to work is first to write out all the code I need to make something work correctly, then I go back over the code to see if there's anything that could be simplified or split into separate functions, etc.
I really like to see DRY code, but if you have to make a helper function that takes a bunch of parameters with a bunch of conditionals to something slightly different, you might be better off just sticking the specific logic you need in each place.
The worst case of copy-pasta I saw in a codebase I came into was a function that was 1000 lines long, duplicated 3 times with < 10 lines of it different for each copy. That's a classic case for DRY to be applied.