All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Why booleans are overused in programming and what to use instead

By

vidyesh

9mo ago· 7 min readenInsight

Summary

The article argues that booleans (true/false values) are overused in programming and should often be replaced with more expressive types like enums, custom types, or polymorphic solutions. It explores common patterns where booleans hide more meaningful design choices, such as function parameters, state flags, and configuration options. The author advocates for replacing booleans with richer types to improve code clarity, maintainability, and domain modeling.

Key quotes

· 4 pulled
In almost every single instance when you use a boolean, it should be something else.
Doing this is worth the effort. It tells you a lot about your system, and it will improve your design (even if you end up using a boolean).
The trick is figuring out what 'something else' is.
There are a few possible types that come up often, hiding as booleans.
Snippet from the RSS feed
One of the first types we learn about is the boolean. It's pretty natural to use, because boolean logic underpins much of modern computing. And yet, it's one of the types we should probably be using a lot less of. In almost every single instance when you

You might also wanna read