4 ms·
Sometimes you can make the dependency graph look nicer, but make your code less readable. Compare the example with the "isPremium" flag, and the example with ca
by kgeist 5y ago
Sometimes you can make the dependency graph look nicer, but make your code less readable. Compare the example with the "isPremium" flag, and the example with callbacks. I've seen many times when a nice readable code becomes a garbled mess after a refactoring to make it more architecturally sound. What's more important?
- rightbyte 5y agoYe the concept of "code smells" is a code smell. What exactly is wrong with explicit and clear handling? Too long functions for Clean Code? He just trades vertical function length for depth and depth is harder to keep in your head.
- layer8 5y agoThe 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.