3 ms·
The trade-off is with future evolution of the code. If the common logic changes in the future, then with the first version it has to be updated consistently in
by layer8 5y ago
The trade-off is with future evolution of the code. If the common logic changes in the future, then with the first version it has to be updated consistently in multiple places, because it duplicates the common logic. In practice it happens quite often that such code is modified/evolved inconsistently.
The more explicit version may still be the better trade-off, but in general it’s not a clear-cut question.
- rightbyte 5y agoSure. Either way might be better depending on circumstances. It is when rule of thumbs are applied dogmatically the result suffers. And there are alot of dogmatic programmers in my experience. Eg. I have noticed some collegues want a functional programming like flow of constant value objects, but they don't think about that they are essentially storing the state in the code path instead. Etc.