4 ms·
> when there's a shared well-defined concern/responsibility I think a good test for this is if you can write a reasonable unit test for the code in question. I
by gregmac 8y ago
> when there's a shared well-defined concern/responsibility
I think a good test for this is if you can write a reasonable unit test for the code in question. If your unit tests essentially become two separate sets of tests, testing the different branches of code, it's probably the wrong abstraction. If your tests work and you've built a reasonable standalone library (even if it's not useful to anything but your exact product), that's at least a signal the abstraction is sustainable.
Now we simply need a formal objective definition of "reasonable code" and the industry should never have this problem again.
- dlubarov 8y agoEven if some shared code is currently branch-free though, it may be unlikely to remain that way if the abstraction is fragile. A red flag is vague function names like "processThing" or "afterThingHappens". If a function can't be summarized concisely, it's probably doing too many things, and the abstraction is likely to break down later when the callers' needs diverge.