Tag: Java
-
SLF4J, Logback, and Log4j: A Straightforward Guide to Java Logging

The Java logging ecosystem features SLF4J as a facade API, with Logback and Log4j2 as underlying implementations. Using SLF4J decouples application code from logging frameworks, allowing easy dependency changes. For most projects, SLF4J with Logback is recommended, while Log4j2 is better for high-performance needs, ensuring efficient logging strategies.
-
Flyway vs. Liquibase: Which Database Migration Tool is Right for You?

Database migrations are essential in modern application development for managing schema changes. Flyway offers simplicity with raw SQL migrations, suitable for single-database projects. In contrast, Liquibase provides advanced features like changelogs and rollback support, making it ideal for database-agnostic applications. The choice depends on project requirements and team expertise.
-
Layered Architecture in Java: A Practical Guide to Keeping Your Code Clean

The post emphasizes the importance of structured programming to avoid spaghetti code, advocating for a layered architecture. It delineates three layers: Presentation, Business, and Data layers, each with distinct responsibilities. Defining a clear structure early in project development facilitates effective teamwork and ensures scalable, maintainable applications by keeping concerns separate.
-
3 JVM Parameters You Must Know

Proper configuration of JVM parameters significantly enhances the performance and stability of Java applications in production. Key areas include setting appropriate heap sizes, effectively managing out-of-memory scenarios, and selecting the right garbage collector based on workload needs. Implementing these optimizations ensures consistent performance during high-demand periods.
-
Mastering Data Validation in Java Applications

The article emphasizes the importance of validating data before it enters the database to prevent issues like NullPointerExceptions and inconsistent data. It advocates for early validation at both the controller and domain model levels, using annotations and custom validators for cleaner, simpler code, ultimately leading to enhanced application reliability.
-
Multi-Environment Configuration in Spring Boot

In this article, I talk about the importance of proper configuration in Spring Boot applications across multiple environments. By using Maven profiles, environment variables, and CI/CD pipelines, developers can maintain clean and flexible configurations. The goal is to ensure a seamless application experience whether running locally or in production, without the risk of misconfigurations.
-
Optional vs Null

The article discusses the limitations and proper use of Optional in Java to prevent NullPointerExceptions. While Optional offers a way to avoid nulls, it doesn’t eliminate the need for thoughtful design. It emphasizes functional programming techniques to handle empty values effectively without excessive null checks, advocating for clearer code over mere null avoidance.
-
How to Create a Singleton with Java Enums

The Singleton Design Pattern ensures a class has only one instance, facilitating global access. Traditional implementation can lead to issues in multi-threaded environments. A more efficient approach using enums guarantees thread-safety, with built-in properties resembling a Singleton. While useful, overusing this pattern complicates testing and should be approached cautiously.
-
How to Organize the Packages of your Project?

Struggling with the eternal Java dilemma of how to organize your project? You’re not alone. From feature-focused structures to classic layer-based setups, choosing the right package organization can make or break your sanity (and your code). In this article, we explore how to structure your Java project effectively, whether you’re working on a sleek online…
-
Authenticate Your Spring Application With AWS Cognito

Recently, I needed to create an authentication system for one of my applications. But I need to create it quickly and securely. I may use a JWT with email and password, but people are lazy creating new passwords. So, I choose for a social Sign-In with AWS Cognito.
