Tag: java

  • âś… Recommended Exceptions Strategy

    ,

    Use a Hierarchy of Custom Exceptions with Specific Messages 1. Define a base exception class Create a generic custom exception that extends RuntimeException (or Exception if you need checked exceptions). 2. Create a few meaningful subclasses for common domains Use subclasses only for distinct categories, not every input field. 3. Throw exceptions with detailed messages…

    exception
  • 🚨 Already Had Problems with Concurrency?

    ,

    Here’s How to Face and Overcome It in Spring Boot Concurrency issues in applications—especially those backed by relational databases—can cause data inconsistencies, lost updates, or phantom reads that are hard to detect and even harder to debug. Have you ever seen something like: If yes, you’re not alone. These are classic symptoms of concurrent modification…

    Car Clock
  • “Which Java Collection Should I Use?”

    ,

    Choosing the Right Data Structure for Real-World Problems Have you ever asked yourself which data structure you should use to store your collection of items?It’s a common question every Java developer faces, especially when writing scalable and maintainable code. Java’s Collections Framework offers a variety of implementations for lists, sets, and maps—but using the right…

    java colection
  • Ever Struggled Sending Dev Emails to Prod?

    , ,

    Use @Profile to Stop That Madness Situation We’ve all been there: you’re building a feature that sends emails—maybe it’s a password reset, a newsletter, or a welcome message. You test it locally, everything looks good, and then… you forget to switch something before deploying. Suddenly, real users are receiving test emails with dummy links or…

    email prod wentwrong
  • Mastering IoC in Java

    ,

    10 Powerful Features Explained with STAR Method, SOLID Principles & Real Code Understanding Inversion of Control (IoC) is essential for writing maintainable, scalable, and testable Java applications. This post explores 10 IoC features using real-world situations, and shows how they align with SOLID principles — with real code to bring everything to life. 1. Decoupled…

    10 IOC technics
  • Understanding One-to-One Relationships: Database vs Java (Hibernate)

    , , , ,

    When modeling One-to-One relationships, you can approach it in several ways depending on the ownership, lifecycle, and data modeling constraints. While Java and Hibernate offer flexibility in how this relationship is implemented at the code level, the root of it lies in database design. So let’s start there. One-to-One Relationship Strategies in Database Engineering In…

    Sql Diagram
  • Mastering MapStruct

    ,

    @Mapping, @AfterMapping, and @MappingTarget in Action đź§© Introduction In modern Java applications, especially with frameworks like Spring Boot, object mapping is a common task. Whether you’re transforming DTOs into entities or mapping between domain layers, doing this manually is tedious and error-prone. MapStruct is a compile-time code generator that simplifies this task—fast, type-safe, and easy…

    MapStruct