Posts

Showing posts with the label code

[15th December 2024] Interesting Things I Learnt This Week

Image
1. Why you should never use !! in Kotlin - Using double-bang operator(!!) is a bad practice; multiple alternatives cover every other possible case. Using it is a hack and a shortcut that will backfire while not saving you much time at the time of writing using it. You shouldn’t use it unless you're writing a short personal script. My Take : The double-bang operator (!!)  which throws null pointer exception in Kotlin might very well be considered " Billion Dollar Mistake ." While it offers a concise way to assert that a variable is not null, I believe it's preferable to have slightly more verbose code that explicitly handles nullability and avoids potential runtime exceptions. Null pointer exceptions have plagued programmers for decades, and introducing a feature that can easily lead to them seems counterproductive. I'm uncertain whether all Kotlin linters currently check for excessive or inappropriate use of the !! operator, but if yours don't, I strongly re...

[17th November 2024] Interesting Things I Learnt This Week

Image
 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...

[10th November 2024] Interesting Things I Learnt This Week

Image
1. One Company A/B Tested Hybrid Work. Here’s What They Found. - Recent research has revealed that a hybrid work model, where employees work from home three days a week, can significantly boost employee satisfaction and reduce turnover rates. This not only improves employee morale but also saves companies millions of dollars in recruitment and training costs. To successfully implement a hybrid model, businesses should prioritize rigorous performance management systems, coordinate team and company-wide schedules, and secure leadership support. Moreover, executives should experiment with different management practices to optimize their approach and maximize the benefits of hybrid work. My Take : There have been too many debates about remote work versus office work. I would have loved to see data comparing the effectiveness of remote, hybrid, and office-based work. I've worked at companies that mandated office work, like Tata Elxsi, where we didn't have laptops and had to rely on...