Guard clauses

Here’s a very simple idea that can make your code a lot easier to read. First, take in the following function: void describeEating(Item item) { if (!item.isFood) { print("Wait, that’s not even food!"); } else { if (item.isDelicious) { print("Hmm, that was good."); } else { print("Not bad. Nutritious."); } } } (Snippets on this […]

Categories
Article

You’re not building a career, you’re playing it

Success is always a product of two things: luck and effort. Nobody became successful because of sheer luck and zero effort. Nobody became successful because of sheer effort, and no luck. Remember, luck can come in many ways. My parents weren’t dirt-poor — luck. My parents weren’t rich — luck (I believe rich upbringing often […]

Variable shadowing

True to the nature of this blog, this is an article about an intermediate software engineering topic. Nothing breathtaking if you’re a senior developer, but hopefully useful to some of the self-taught programmers out there. Try to catch the bug in the following function: void prepareDeliciousMeal(Fridge f) { final e = f.getEgg(); // … more […]