Inversion of Control vs Dependency Injection

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. …

Understanding floating-point numbers

Floating-point numbers vs real numbers Understanding floating-point numbers is essential when working with decimal values. Floating-point numbers may also be used to work with whole numbers that do not fit in a long integer (at the expense of losing precision). In any case, you don’t want to be caught off guard when seeing this: In …

Negabinary base

The negabinary base, and in general any negative-base system, allows the representation of negative numbers without the need of using a minus sign. Calculation by hand To get some intuition about how this works, let’s consider the negabinary base (). In this base, each position represents a power of : and therefore: 4-2 4-2+1 4+1 …

Testing the limits of your application

When we first learn to program, we are taught to be mindful of the computer’s resources; they must be used sparingly and released as soon as possible. So you know the drill: close files, release database connections, close sockets, free memory, etc. But have you ever wondered who sets the limits of what can be …

This would not happen with Java

One of the main differences between C and Java is the capability of C to perform low-level memory operations. This allows for great power and flexibility but is also a constant source of bugs. In that sense, Java is considered a safer programming language. This post presents some examples in C that would not happen …

Future beginning and end in Scala

A common issue noticed when reviewing pull requests is the understanding of the boundaries of Futures. In most cases, people take for granted that given a function with this signature the full body of the function will be executed in the Future. Let’s look closely into this with a couple of examples Example 1 Here’s …

Java Date and Time API explained by example

The handling of dates and times is a sure source of pain and confusion. While time is a familiar concept that everybody knows intuitively, it is difficult to formalise when developing an application. This post aims to shed some light by presenting different use cases implemented with Java Date and Time API. Flight tickets The …

How to construct objects in Scala

Scala’s object-oriented programming style comes with some syntactic sugar and a few tricks. In order to get a better understanding of how Scala works, we will examine a few Scala examples and the corresponding byte code (in reality, the Java code resulting from decompiling the class files). Examples Empty class Simplest possible example, an empty …