3 ms·
I usually look at this in the form of “layers”. If you have a lot of duplicated logic, its a lot nicer to abstract those concerns into a “layer” of functions /
by seer 6y ago
I usually look at this in the form of “layers”. If you have a lot of duplicated logic, its a lot nicer to abstract those concerns into a “layer” of functions / classes.
Whats important is to not have leaky abstractions though. The moment you need to start reading into those functions is the moment you realize you would have been better off leaving the code as is.
Its very hard (at least for me) to come up with those layers and requires a ton of iteration. Thats why I also prefer the top example - you need to work with the lower level code first, and go through enough of it before you can start spotting patterns and creating layers, otherwise you’re bound to mess things quite a bit.