[17th November 2024] Interesting Things I Learnt This Week
1. Booleans are a trap : Booleans, while seemingly simple, can introduce complexity and limitations into domain modeling. When used to represent complex states, booleans can lead to unclear code and potential errors. To avoid these pitfalls, consider using enums or enum sets. These approaches provide a more expressive and maintainable way to model complex states in your applications. My Take : I wish I had learned this earlier in life. When working with Google Docs, I realized the limitations of booleans. Expanding boolean-based behaviors often led to adding more fields, making the system complex. Enums would have provided a simpler solution. The problem wasn't just the booleans themselves, but also the need to pass them through multiple layers of the stack, often requiring additional parameters. Another important aspect of enums is the inclusion of an " enum not specified " state. This state explicitly indicates that an enum value hasn't been set, which can be usef