3 ms·
What is the way to do it? I like having functions with expressive names to encapsulate/hide complexity, and to comment what I'm doing. If it is not obvious why
by UweSchmidt 7y ago
What is the way to do it?
I like having functions with expressive names to encapsulate/hide complexity, and to comment what I'm doing. If it is not obvious why "20" is such a big deal in your code, then that's where I would trip up.
I don't mind having a few ifs if they look like this:
if (isHoliday()) { }
else if (isWeekend()) { }
- Sharlin 7y agoSure. But complex if/else logic, like I said, is often a code smell that indicates that the behavior might be better off abstracted out to a polymorphic entity of whatever sort is idiomatic in your language. There are a lot of "If statement considered harmful" style articles on the web, but I can't seem to find the specific one I had in mind :/