4 ms·
Make the impossible states unrepresentable using an enum of only the possible boolean combinations.
by cma 2y ago
Make the impossible states unrepresentable using an enum of only the possible boolean combinations.
- dpig_ 2y agoIsn't that exactly what the article prescribes?
- liontwist 2y agoDid you read the context?
- cma 2y agoNo I read wrong and missed it. If all four states are actually possible an enum can still be a win if you have a compiler that can check for exhaustive switch case statements. Or especially if updating a system where it used to be only three were valid and now something changed so that all four are.