Java features explained with examples

The power of generic algorithms

In computer science, there is this tension between creating generic algorithms applicable to different situations and optimising an algorithm to solve a specific problem. Generic algorithms make it possible to find similarities between problems that, at first glance, may seem completely unrelated. This is especially interesting when those problems belong to different domains. When this […]

Traps for numbers

This post is a playful combination of maths and computing to design “traps for numbers”. Here is the accompanying code to this post along with its tests. Collatz sequence Many classical problems in maths can be given a new twist with the help of computers, resulting in surprising results. One of these problems is the […]

Using Composite Java pattern to switc...

Design patterns is probably one of the most popular topics in the Java blogosphere. Yet many times the examples used to illustrate the different design patterns are not very engaging. To remedy that, this post explains the Composite pattern in a fun way. Since there are already many descriptions of this pattern out there, we […]

Java phasers made simple

I recently came across Java phasers while reviewing different constructs for inter-thread communication. Phasers are associated to the concepts of fuzzy barriers and point to point synchronisation which are all well explained on this parallel programming course. As to this post, I will borrow the example of the one-dimensional stencil to explain very intuitively the motivation behind the concept of […]

Inversion of Control vs Dependency In...

Background Lately, I have been interviewing candidates for a Developer role and realised how much confusion there is, still, around the concepts of Inversion of Control and Dependency Injection. The majority of people use both terms interchangeably. Probably, the confusion derives from the heavy use of those concepts on Spring, where Inversion of Control is used to enable Dependency Injection. […]

Object-Relational Mapping pitfalls

Background Object-Relational Mapping (ORM) has become an indispensable tool to work with relational databases in Java applications. This topic, along with JPA and Hibernate, has been the subject of innumerable articles. Therefore, the present post will not enumerate again the pros and cons of using these tools but describe a real situation involving the misuse of ORM.   […]

How to keep your microservices straig...

Here is a post about… microservices and Docker, what else? With this post I want to illustrate the recent problems I have had at work to deal, on my local environment, with all the microservices that form part of our infrastructure. There is a lot of literature about microservices and the challenges of adapting Production environments to […]

Tuning an Akka application

This post presents an example of how to tune an Akka application. The first section presents the application (actually, a simple microservice) that will be used along this post to illustrate the tuning process. The second section describes the load tests and tools that will be used to measure the application performance. Next section presents different test scenarios […]

Unveiling blocking operations

Background Developing an application following the reactive principles can be quite challenging, specially when working with third party libraries, as these may not be fit for purpose, i.e. blocking operations. In such cases, the first challenge is to find the blocking operation and the second to confine it so that it does not affect the rest of the […]

Challenges of building a Dev environm...

Background One of the main difficulties when developing an application is “imagining the form” of the application on the Production environment. The components/services that developers use to build the application on their local environment may differ greatly of those used on the environments of the deployment pipeline. Admittedly, technologies like Vagrant and Docker aim to make […]