Deceptive Booleans
We've been looking at some of the issues around using primitive types too often.
Primitive types should be the building blocks out of which we create more useful business-oriented concepts/abstractions in our code.
Again, this helps each specific business concept to have all of its logic in one place (which means we can share it and reason about it much more easily), implement more robust error handling, reduce bugs, and so on.
In this section, I want to look at the most common cause of primitive overuse that I've experienced. I see it all the time.
Like many of our code smells, it's deceptively simple at first glance.
Scenario
In our scenario, we're working on a web application that helps clients to sell their used items online.
We've been asked to add some extra rules around the part of our system that authenticates users.
Right now, the system only checks whether a user was successfully authenticated:
const isAuthenticated...