DEV Community

Discussion on: Hide the constant, abstract the code

Collapse
 
macsikora profile image
Pragmatic Maciej • Edited

Yes sure, you are right. In this situation the win is arguable, as the logic is very simple. So for sure I would not make it important so much if this check happens few times, even more if we have static types to support us with this check. But if this check is notorious in the app, and if it is connected with others it is better to abstract it.

For sure examples I made in the article are very simple (maybe even too much). But if we would have some && || copy pasted, so some combined logic then such abstraction would be far more valid.

Thanks for comment!