In my previous article, I spoke about the factory patterns. These patterns are part of creational patterns. In this post we’ll focus on the rest of the creational patterns: the Singleton, the Builder and the prototype.
In this in-depth article I present the advantages and drawbacks of factories. Then I present each type with real examples from famous Java frameworks or Java APIs. I use Java code to implement factories but if you don’t know Java you’ll still be able to understand the idea. I also use UML to present each pattern.
Most JAVA developers are using Maps and especially HashMaps. But how many developers know how a HashMap works internally? In this post, I’ll explain the implementation of java.util.HashMap, present what’s new in the JAVA 8 implementation and talk about performance, memory and known issues when using HashMaps.
There are 4 types of references in JAVA: strong references, soft references, weak references, phantom references.
Those references differ only by the way the garbage collector manages them. If you have never heard of them, it means that you were only using the strong ones. Knowing the difference can help you, especially if you need to store temporary objects and can’t use a real caching library like eHcache or Guava.
Since those types are stongly related to the JVM garbage collector, I’ll briefly recall some information about garbage collection in JAVA and then I’ll present the differents types.
A few months ago, I was confronted at work with the following use case: “Analyse the data of some selected clients”. It seems easy, but not if there are billions of data and there can be millions of clients to analyse and it needs to run as fast as possible!
In this post I’ll describe the solution I found but most importantly, how I came to this solution.
As a java developper, I’ve never heard of the LSP pattern. It was only when I read some stuff about C++ that I encountered this pattern. It’s very strange because this pattern is sometimes seen as one of the 5 principles of object-oriented programming.