Skip to main content

Posts

Showing posts from January, 2025

Error handling in GO, my thoughts.

Go's error handling emphasizes simplicity and explicitness.  This post explores its unique approach and compares it to other languages. Agenda   Why is it an interesting topic in GO? What do we have in different languages? It is why you can trust. Why is it an interesting topic in GO? I like having control over the processing of the source code; that code has a clear and structured flow, and it helps to read and understand the code and what's going on here. GO has it. And that's all that GO has. You are limited to processing it ONLY in this way. GO developers are discussing that it is a problem that you need to write each time mechanism to validate the error state and handle it on each layer of the process flow. And YES, it is noisy, I totally agree here. But when I saw this discussion, only one thing in my head. Did you try to debug the bug when you can't see where and who throws this exception? Yeah, it is the wrong implementation, but in my experience, I saw it very ...

Hints and Hacks: Mastering Go Project Structure and Generic Repositories with GORM

  Mastering Go Project Structure and Generic Repositories with GORM Establishing a robust project structure is paramount when building scalable and maintainable Go applications. Coupled with the flexibility of a generic repository, this approach ensures clean, reusable, and extendable code. In this article, we'll explore how to set up a well-structured Go project and implement a generic repository pattern with GORM, focusing on practical examples and best practices. Why Project Structure Matters A well-organized project structure is critical for: Scalability : Adding new features or components becomes seamless. Readability : Developers can easily navigate the codebase. Maintainability : Issues can be identified and resolved efficiently. Adhering to a modular structure, your application remains clean and manageable as it grows. Recommended Go Project Structure Here is a typical project layout for a Go application leveraging GORM and a generic repository: app_db_generic...

Taming the Shadow: Turning Tech Debt into a Strategic Advantage

Tech debt is one of those topics that can make or break a project.  It's like this ever-present shadow lurking around our cool, innovative ideas. It's necessary sometimes, but when it grows too much, it can weigh everything down like an anchor. 🚀 Here's my spin on how to manage tech debt effectively: - 𝗨𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗧𝗲𝗰𝗵 𝗗𝗲𝗯𝘁: See it as a necessary compromise to get things moving but don’t let it turn into a never-ending burden. - 𝗙𝗼𝗰𝘂𝘀 𝗼𝗻 𝗪𝗵𝗮𝘁 𝗖𝗼𝘂𝗻𝘁𝘀: Align tech debt management with the business's core priorities. Score quick wins but keep an eye on securing long-term success. - 𝗖𝗼𝗺𝗺𝘂𝗻𝗶𝗰𝗮𝘁𝗶𝗼𝗻: Keep the lines open between dev teams and business folks. Everyone should be transparent about tech debt implications and the choices being made. - 𝗔𝗹𝘄𝗮𝘆𝘀 𝗚𝗿𝗼𝘄𝗶𝗻𝗴: Keep things fresh with frequent updates and changes. Be open to the latest tech trends and business shifts. Investing in education is something I hold in...

Introducing educational program: "Innovative Pathways to Leadership"

Want to become a tech lead but tired of info that’s either too technical or just hot air? Let’s shake things up. I'm working on an exciting educational program for those wanting to step up into technical leadership roles. 🚀 Here’s the deal: 1. 𝗕𝗹𝗲𝗻𝗱 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴: We need both tech chops *and* the soft skills. Most programs make you choose. Why not both? 2. 𝗕𝗿𝗲𝗮𝗱𝘁𝗵 𝗼𝘃𝗲𝗿 𝗗𝗲𝗽𝘁𝗵: No, you don’t need to be the expert on every single subject, just need some solid basics. Know the principles. Understand the key ideas. 3. 𝗨𝗻𝗶𝗳𝗶𝗲𝗱 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: Get familiar with both technical elements and the non-technical stuff in one place. It’s not about being the best coder or the best manager. It's about combining skills and mindset to lead effectively. 4. 𝗛𝗮𝗻𝗱𝘀-𝗼𝗻, 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗮𝗹: Reading is good, but doing is better. Real-world scenarios and challenges build experience and confidence. Creating this unique program involves a mix of inspiration, educa...

Hints and Hacks: Minimize using Exceptions .NET

Microsoft recommends against using exceptions for regular program flow, as they are slower than other control flow methods. Exceptions should be reserved for handling rare or unexpected situations, not the usual flow of the program. ( Microsoft Docs: Best Practices for Exceptions - .NET | Microsoft Learn ) A more efficient and elegant alternative is to use a Result object, which effectively represents the outcome of an operation. This approach communicates the result clearly without relying on exceptions, offering simplicity and clarity. Why use the Result object? Improved expressiveness:  The function signature clearly indicates possible outcomes, making the code more self-explanatory. Better performance:  This method avoids the performance overhead of throwing and catching exceptions, especially in scenarios where errors are anticipated. Consistent error handling:  Errors are turned into values that can be passed, modified, or logged easily, creating a more predictable ...

Why I Started Using .http Files

I recently discovered how convenient it is to use .http files for API testing directly within an Integrated Development Environment (IDE). This method has proven to be an efficient and streamlined way to manage API interactions. Here’s a closer look at how this approach is enhancing my workflow: What Are .http Files? A .http file is a simple text file that defines HTTP requests. When equipped with the right extensions, .http files can be executed directly from some IDEs, such as JetBrains IntelliJ IDEA, WebStorm, or Visual Studio Code. This setup allows me to write and send HTTP requests without needing a dedicated API client tool like Postman or using curl commands in the terminal. Key Benefits of Using .http Files Convenience: I can stay focused in a single environment by enabling API testing within the IDE, minimizing context switching, and boosting productivity. Version Control Integration: Storing .http files in the project’s version control system allows my team and I to share, r...

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.