In this Engineering With Java newsletter edition, we have hand-picked 10 interesting Java and Spring articles worth reading. Topics include Java 23, coding standard Spring Boot, writing flexible unit tests, server-side rendering with Spring Boot, best practices for DTO, etc.
Java 23 Has Arrived, And It Brings a Truckload of Changes
This article discusses Java 23 and highlights its significant changes, including updates to Project Loom for virtual threads, Project Panama for improved foreign function and memory support, and Project Amber for enhancing Java’s syntax and patterns.
Java 23 also focuses on performance improvements, with advancements in garbage collection and runtime optimizations.
Other notable additions include sealed classes, record patterns, and better diagnostics for developers. The release emphasizes simplicity and efficiency, aiming to modernize Java further.
How to follow good coding standards in Spring Boot
This article on Java Revisited offers guidelines for following good coding standards in Spring Boot. It emphasizes the importance of writing clean, readable, and maintainable code by adhering to principles like proper package structuring, clear API documentation, and using dependency injection wisely.
It also highlights best practices such as avoiding cyclic dependencies, writing tests, and handling exceptions appropriately to ensure robust applications.
How to Write Unit Tests Which Won't Tie Our Hands
This article emphasizes the importance of writing unit tests that remain flexible and maintainable over time. It argues against creating tests that are tightly coupled to implementation details, which can make refactoring difficult.
The author suggests focusing on testing the behavior of the code rather than its internal structure, using techniques like mocking dependencies. He also highlights the need for clear and descriptive test names to improve readability.
Ultimately, the article provides insights on writing effective unit tests that support ongoing development without hindering changes.
🚀 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.
A beginner’s guide to Spring Data Envers
This article discusses integrating Spring Data with Hibernate Envers to manage entity auditing in applications. It explains how Envers allows for versioning and tracking changes to entities over time, providing a historical view of data.
The author details the configuration required to enable auditing, including annotations and properties for entity classes. He also highlights best practices for querying audit data and using custom queries to retrieve historical versions.
Overall, the article serves as a comprehensive guide for implementing auditing with Spring Data and Hibernate Envers effectively.
Asserting REST JSON Responses With REST-assured
This article explains how to use Rest Assured to test JSON responses in Java. It covers key techniques for validating JSON structures, such as checking response status codes, verifying JSON fields, and asserting complex nested fields.
The article demonstrates how to use assertions like
body()
,hasItem()
, andequalTo()
for validating JSON properties and ensuring the response matches expected outcomes.
Using MockMvc With SpringBootTest vs. Using WebMvcTest
This article compares
MockMvc
and@WebMvcTest
in Spring testing.MockMvc
is a flexible testing tool that simulates HTTP requests and allows for full integration tests of the web layer.@WebMvcTest
is a more focused annotation used to test only the MVC components, isolating the controller layer and excluding other application components like services.The guide also discusses when to use each approach based on testing needs.
The Persistent Threat: Why Major Vulnerabilities Like Log4Shell and Spring4Shell Remain Significant
This article explains why vulnerabilities like Log4Shell and Spring4Shell remain persistent threats despite being disclosed and patched years ago. Many applications still run on outdated and vulnerable versions of these libraries, leaving systems open to potential exploits.
The article emphasizes the importance of maintaining security in software development and encourages developers to update dependencies regularly and use security tools to mitigate risks.
🚀 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.
Server-Side Rendering With Spring Boot
This article explains how to implement server-side rendering (SSR) with Spring Boot. SSR improves web application performance by generating HTML on the server instead of relying solely on JavaScript in the browser.
The article walks through setting up a Spring Boot application, using Thymeleaf for template rendering, and highlights the benefits of combining SSR with modern front-end frameworks. It also touches on performance, SEO benefits, and handling dynamic content.
Observability Agent Architecture
This article from DZone discusses the architecture of observability agents, which collect and transmit telemetry data (logs, metrics, traces) from applications to centralized platforms.
It covers key design principles like efficient data handling, minimizing performance overhead, and ensuring security. Techniques such as bytecode weaving (for languages like Java) and monkey patching (for dynamic languages like Python) are explored for instrumenting applications.
The article also emphasizes the importance of self-monitoring, robust error handling, and using standards like OpenTelemetry.
Best Practices for Using DTOs in Java
This article on Java Code Geeks outlines best practices for using Data Transfer Objects (DTOs) in Java applications to enhance performance by reducing method calls.
It recommends keeping DTOs simple and focused on data representation without business logic. Libraries like MapStruct or ModelMapper can help minimize boilerplate code for mapping.
The importance of validation, managing DTO versioning, and using immutable DTOs for thread safety is emphasized.
Finally, it advises safeguarding sensitive data in DTOs exposed through APIs to ensure security.