Skip to main content

Hints and Hacks: Make your code better (Intro)!

This is my first post about Hints and Hacks. For this initial post, I’ve selected some simple and humorous tricks, which happen to be my ‘favorite’ types of code commonly seen by beginner or exhausted developers. I often find myself commenting on these during the code review process. One common situation is when you need to add a method to check if some data is valid. Here’s how it typically looks:

private static bool IsValid(string name)
{
    if (string.IsNullOrEmpty(name))
    {
       return false;
    }
    else 
    {
       return true;
    }
}

OR

private static bool IsValid(string name)
{
  return !string.IsNullOrEmpty(name) ? true : false;
}

Please DON’T do that. Just make your code as simple as possible and always think about the readability of your code. So, how it should be:

private static bool IsValid(string name)
{
  return !string.IsNullOrEmpty(name);
}

In this implementation, this method will be clean and understandable for everyone.



Comments

Popular posts from this blog

Microsoft Azure Well-Architected Framework - Maturity models

The Azure Well-Architected Framework has always been a great way to assess and review workloads. But with the recent updates—especially the introduction of maturity levels —it’s becoming much more than just a checklist. 💡 It’s evolving into a concept. Not only can teams review their architecture, but they can now score, track progress, and continuously improve . The maturity model provides clear stages—from establishing a solid foundation to achieving future-proof agility—making it easier to understand where you are today and where you should aim tomorrow. Why is this important? ✅ It transforms reviews into a roadmap for growth ✅ It allows measurable scoring of architecture maturity ✅ It pushes teams to focus not only on compliance, but also on resilience, agility, and future-readiness Each update makes the Azure Well-Architected Framework better and stronger —helping organizations align technology decisions with long-term business success. 👉 In my view, this is the right dire...

Coinbase x402 is great option for paymant per request!

  🚀 What is Coinbase x402? x402 is a new open payment protocol built by Coinbase that revives the long-forgotten HTTP 402 “Payment Required” status and turns it into a modern, internet-native payment layer . Using stablecoins (such as USDC ) directly over HTTP, x402 allows services: APIs, websites, or digital content platforms to charge per request. At the same time,  clients (including AI agents and automated systems ) can pay programmatically , without accounts, subscriptions, or human interaction. In simple terms: request → pay → get response , all at the protocol level. How It Works (Simplified) A client requests a protected resource (API, data, article, service). The server responds with HTTP 402 Payment Required , including payment instructions. The client (app or AI agent) generates a payment transaction using its wallet. The client resends the request with payment details included in HTTP headers. The server verifies the payment and immediately ret...

"Dushnylo" Series: What do you know about "Logging-Oriented Programming"

I’ve seen it too many times: developers don’t know how to use logging correctly. We end up with tons of logs, everything dumped in, debug left in production, and  even API keys and secrets leaking out. Why does this still happen? Because we’ve slipped into LOP  (Logging-Oriented Programming) . Just throw in logs everywhere and hope: “we will see what happens here.” WHY WHY WHY!!! The real reason? Most of the time, we are just tired and don’t know how to debug locally. Maybe it needs a 3rd-party integration, maybe we can’t prepare the right data, maybe something else. I’m not asking you to “please use logs correctly.” If you need to debug your code, configure remote debugging or run it locally. So, just: 🚨 Do NOT use LOP. Be a good Software Engineer! 🚨