Simplifying Conditional Logic
In this article I will go over three ways you can better write your code's conditional logic, making it more readable, easier to understand, and work with.
Prefixes
In order to explicitly convey that a variable is a boolean variable, you can prefix i...
tigerabrodi.blog2 min read
Ákos Kőműves
Full-Stack Developer and Writer
Agreed with everything, except:
hasMoreThanFiveArticlesis overkill & strong coupling for the following reasons:if the limit changes to 4, now you've got a function name to update.
You could argue that ha! I'm going to pass in the limit as a parameter:
hasMoreThanNArticles(user, 4)but if you look back, you'll realize, you've been bikeshedding on this the whole time:
if (user.articles > 5)that's just the cleanest way possible to tell & write if there are more than 5 things of something.