Executable Specifications are tests that can also serve as design specifications. They enable technical and business teams to get on the same page by enabling the use of a common language (in DDD-world this is also known as Ubiquitous Language). They function as documentations for the future maintainers of the code. In this article we will see an opinionated way of ...
Read More »Home »
A Beginner-friendly Introduction to Kubernetes for Developers: What is Kubernetes?
Just a few months ago, I had the chance to get my hands dirty with Kubernetes for the very first time. Up until that point, all I knew about it is that it is something that ensures containerized applications run smoothly in a cluster, nothing else. After finishing my “hello world” and trying out some examples, I have decided to ...
Read More »Different States of Java Threads
Introduction In Java, threads can have States. The Thread.State enum defines the different states that a Java thread can have. This enum defines the following values – NEWRUNNABLEBLOCKEDWAITINGTIMED_WAITINGTERMINATED In the subsequent sections, I provide a brief overview of these states along with possible transitions between them. States of a Java Thread NEW This is the default state a thread gets ...
Read More »A brief overview of the Fork/Join Framework in Java
Introduction The Fork/Join framework is a framework to solve a problem using a concurrent divide-and-conquer approach. They were introduced to complement the existing concurrency API. Before their introduction, the existing ExecutorService implementations were the popular choice to run asynchronous tasks, but they work best when the tasks are homogenous and independent. Running dependent tasks and combining their results using those ...
Read More »Java Tips: Creating a Monitoring-friendly ExecutorService
In this article we will be extending an ExecutorService implementation with monitoring capabilities. This monitoring capability will help us to measure a number of pool parameters i.e., active threads, work queue size etc. in a live production environment. It will also enable us to measure task execution time, successful tasks count, and failed tasks count. Monitoring Library As for the monitoring ...
Read More »JPA Tips: Avoiding the N + 1 select problem
Introduction ORM frameworks like JPA simplifies our development process by helping us to avoid lots of boilerplate code during the object <-> relational data mapping. However, they also bring some additional problems to the table, and N + 1 is one of them. In this article we will take a short look at the problem along with some ways to ...
Read More »Replacing exceptions with error notifications during input validation in Java
In my previous article I wrote about an input validation design which replaces hard-to-maintain-and-test if-else blocks. However, as some readers pointed out, it has a drawback – if the input data has more than one validation errors, then the user will have to submit the request multiple times to find all of them. From a usability perspective this is not a ...
Read More »Clean Code from the trenches
Clean Code from the trenches – Validation Let’s directly start with an example. Consider a simple web service which allows clients to place order to a shop. A very simplified version of the order controller could look something like below – @RestController @RequestMapping(value = "/", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public class OrderController { private final OrderService orderService; public ...
Read More »Dealing with Java’s LocalDateTime in JPA
A few days ago I ran into a problem while dealing with a LocalDateTime attribute in JPA. In this blog post I will try to create a sample problem to explain the issue, along with the solution that I used. Consider the following entity, which models an Employee of a certain company – @Entity @Getter @Setter public class Employee { @Id ...
Read More »