ServiceLoader module

Migrating the ServiceLoader to the Java 9 module system

A long long (long?) time ago, I wrote a post about the ServiceLoader. In short, the Service Loader allows to separate an API and its implementations in different JARs. The client code depends on the API only, while at runtime, the implementation(s) that is (are) on the classpath will be used. This is great way to decouple the client code from the implementing one. For example, the ServiceLoader is used by SLF4J: one adds the slf4j-api on the classpath at compilation time, while any single impl

Docker industrialization ONBUILD

ONBUILD, the overlooked Docker directive

It’s hard to ignore Docker nowadays. There are a lot of blog posts available on the Web. The problem is that most always repeat the same. In this post, I’d like to focus on one directive that I find overlooked via a use-case: it is Java specific, but the parallel can be easily drawn to other tech stacks. The problem The situation is the following: as a developer, I’d like to use Docker as a way to package a JAR from the sources of my application. As a reminder, here’

hibernate query JPA persistence

Hibernate's Query-By-Example

Despite the current trend regarding &nbps;ORM frameworks, I never had any issue using JPA nor Hibernate. I must admit that my use-cases were pretty simple. Also, since that was already some years ago, we hosted those applications on our own on-site infrastructure so that the search for the ultimate performance - and its associated savings - was not a goal; empowering junior developers who were not familiar with a lot of technologies was. Interestingly enough, Hibernate actually predates JPA, so

exercise programming style mapreduce

Exercises in MapReduce Style

This is the 19th post in the Exercises in Programming Style focus series. In the last episode of Exercises in Programming Style, we solved the word frequency problem with the Hazelcast library. This time, we are going to use MapReduce for that. MapReduce is a process consisting of two steps: Map performs transformations, filtering and sorting into different queues. Reduce aggregates the content of the queues into a result.

exercise programming style

Exercises in Programming Style: sharing data among threads

This is the 17th post in the Exercises in Programming Style focus series. Last week, we solved the word count problem using the Actor model: objects running on different threads and communicating through messages. This week, we will drop objects, and use data structures that are shared among the threads: such a shared structure is called data space in the book. The original Python code uses two dedicated data spaces.

exercise programming style

Exercises in Concurrent Programming Style

This is the 16th post in the Exercises in Programming Style focus series. In the book, this chapter is called Actors. In software, the actor model is a very specific way to design code: The actor model in computer science is a mathematical model of concurrent computation that treats 'actors' as the universal primitives of concurrent computation. In response to a message that it receives, an actor can: make local decisions, create more actors, send more messages, and determine how to respond to th

exercise programming style

Exercises in Programming Style: spreadsheets

This is the 15th post in the Exercises in Programming Style focus series. Last week, we solved the top 25 word frequencies problem with the help of the database. This week, we will get back to solve it with code alone. The design is to model the problem as a spreadsheet. The spreadsheet holds a number of cells, each cell having a value and a formula. Just like in regular spreadsheet, the formula is a function that might reference another cell’s value, and computes the current cell’s v

exercise programming style RDBMS

Exercises in Relational Database Style

This is the 14th post in the Exercises in Programming Style focus series. So far, we solved the word frequencies problem with code alone. This week, we will solve it with the help of infrastructure. And with this specific problem at hand, what better fit than the database? We can approach the problem by loading the data read from the files in the database, and retrieving the top 25 words with the relevant query.