In this Engineering With Java newsletter edition, we have hand-picked 10 interesting Java and Spring articles worth reading. Topics include SQL, Spring AI, Decorator Pattern, Bean Validation, etc.
I hope enjoy the reading!
🚀 Ace Your Next System Design Interview 🚀
Taught by a best-selling author, everything you need to take your system design skills to the next level.
SQL Best Practices Every Java Engineer Must Know
This article discusses SQL best practices for Java engineers, focusing on query optimization. Key recommendations include using indexes (including function-based ones), avoiding SELECT *
, using proper joins, filtering data early, and limiting rows returned. The author advises using EXISTS
instead of IN
for large datasets, avoiding functions in WHERE
clauses, using joins over subqueries, optimizing GROUP BY
and ORDER BY
, selecting appropriate data types, using batch processing, and analyzing query plans. Connection pooling is also recommended for efficient database interactions.
Implement Decorator Pattern For Online Payment System
This article explains the Decorator Pattern in Java, particularly for an online payment system. This pattern allows dynamic extension of object behavior without relying on extensive inheritance, which is useful for adding features like fraud detection or logging.
The Bytecode Chicken-Egg Problem
This article explores the "chicken and egg" problem in programming, specifically in building systems where different components rely on each other. It discusses the challenges of determining which component to develop first and how to effectively structure dependencies. The author emphasizes the importance of modular design, versioning, and utilizing APIs to break the cycle and enable incremental development. Ultimately, the goal is to create a robust architecture that can evolve without being hindered by tightly coupled components.
How Functional Programming Can Help You Write Efficient, Elegant Web Applications
This article discusses leveraging functional programming principles to build modern web applications. It emphasizes immutability, first-class functions, and higher-order functions to enhance code maintainability and scalability. The author compares traditional object-oriented approaches with functional paradigms, highlighting benefits like easier testing and fewer side effects. Key concepts include the use of functional libraries, the role of JavaScript in web development, and techniques for effectively managing application state.
🚀 Grokking the Java Interview 🚀
Crack your Java interview by preparing important topics and mastering key concepts in a guided and structured way in a short time.
Dynamic Constraint Application in Java Bean Validation
This article explores dynamic constraint application in Java Bean Validation, highlighting how developers can create flexible and context-aware validation rules. It discusses using the @ConstraintValidator
interface to apply constraints dynamically based on various conditions, such as user roles or specific input values. This approach enhances validation by allowing rules to adapt at runtime, improving maintainability and user experience. The author provides examples and implementation details to demonstrate how to leverage this dynamic capability effectively.
Sorting a List of Pair<String, Integer> in Java
The article explains how to sort a list of pairs in Java, specifically focusing on pairs containing a
String
and anInteger
. It demonstrates the use of Java'sComparator
to sort based on theString
values, and if two strings are equal, it sorts by theInteger
values.The code snippet provided illustrates how to achieve this with a custom comparator, utilizing the
Collections.sort()
method.
Is Spring AI Strong Enough for AI?
The article explores the capabilities of Spring AI, evaluating its integration of AI features within Spring applications. It discusses the framework's offerings for machine learning and AI-driven applications, including easy configuration and extensibility. Despite its promising features, the author questions whether Spring AI can compete with dedicated AI frameworks. Key points include ease of use, support for various AI models, and the need for robust tools to enhance its AI capabilities.
Using Lombok Library With JDK 23
This article discusses how to resolve compilation errors when using the Lombok library with JDK 23 due to changes in annotation processing behavior.
It highlights the need to configure the Maven compiler plugin to enable full annotation processing, which can be done by updating the
maven.compiler.proc
property in the Maven configuration.The author provides a concise solution to avoid errors like "cannot find symbol" when using Lombok annotations such as
@Slf4j
.
Monolithic vs Microservices: Choosing the Right Architecture for Your Team
This article compares monolithic and microservices architectures, detailing their structures, flexibility, scalability, deployment methods, and resilience. Monolithic applications function as a single unit, making them simpler and cheaper to develop, ideal for small projects or MVPs.
In contrast, microservices consist of independent services that can be developed, deployed, and scaled individually, providing better adaptability and resilience for complex, scalable applications.
The choice between these architectures depends on various factors, including project goals, team expertise, and resource availability.
ChatClient Fluent API in Spring AI
This article introduces the Spring AI project, which enables the integration of generative AI capabilities into Spring Boot applications. It discusses key components like the
AiClient
interface, which facilitates interaction with AI models such as OpenAI.This tutorial demonstrates creating a REST API that generates poetry based on user-defined themes and genres using configurable prompts. It highlights the importance of structured responses using DTOs to adhere to REST API standards.