Java features explained with examples

Posts in category Uncategorised

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 […]

Functional programming

This post presents some features of functional programming with Scala. In essence, functional programming is about programming by making use of mathematical functions. All well-known features of functional programming are just a result of using mathematical functions, e.g.: referential transparency immutable state higher-order functions pattern matching I especially like ‘pattern matching’ as it allows for a […]

Dealing with memory leaks

Background This post describes my experience playing around with Scala and some of its concepts like tail recursion and futures. It also offers an opportunity to see how a memory leak can happen and how to analyse it. I created a simple web crawler that takes a seed link (e.g. http://www.bbc.co.uk) and then, recursively (using tail recursion), collects all […]