The Factory Method Design Pattern

What is Factory Method Design Pattern? Gang of Four categorizes the factory method design pattern as a creational pattern since it deals with object creation.  This pattern enforces the loose coupling and encapsulation principles in object-oriented programming. This pattern applies in situations where there are sub-classes involved, and the creation of those becomes complex with … Read more

What is Dependency Injection Design Pattern?

The software world is getting more robust and smart with blooming innovative ideas every day. Every technology is lightened by this smartness which reduces the heavy and complex mechanisms. Emerging frameworks are best examples of those innovations. Those are capable of making the designers and developers’ lives less stressful with many automated features. Containers are … Read more

Multi-Release JARs in Java 9

While developing Java-based solutions, one would have to often include third party libraries to code better. These third-party libraries usually release different releases according to the support matrix they have. This would result in having different library versions targeted for different Java versions. As a result, it would be difficult to ensure that everything works … Read more

Let’s Learn Singleton Design Pattern

What is a Singleton? The word singleton is derived from the word, Single which represents one independently executable unit. In the programming world, a singleton is an object which has only one instance for the life time of the application. What is Singleton Design Pattern? Singleton design pattern is classified as a creational design pattern … Read more

Convenience Factory Methods For Collections In Java 9

In order to create an immutable collection before Java 9, a Java developer had to write code which involves creating a collection, adding elements to it and passing the collection to Collections.unmodifablexxx() method where xxx can be any collection like a set or a list. As a result, the program becomes too verbose. A Java … Read more

Java Tree Data Structure

In this tutorial, we would be creating a Tree data structure in Java. Java does not have a built in tree data structure. Let’s start by creating a tree as shown in the below image. The tree has a Root node and a number of children Java Tree Implementation Building Tree In Java Tree, each … Read more

Java 8 streams – List to Map examples

In this tutorial, we would be looking at the various examples of using streams introduced in Java 8 to create a Map from a List of values. I have been working with Java 8 for quite a while and have found streams extremely useful. Almost every single day I am writing code using streams.  We … Read more

Introduction to Design Patterns

What are Design Patterns? What is a Pattern? Patterns exist everywhere in the world. In culinary, art, medicine, law, mathematics, music, dancing and the list goes on. Genrally, a pattern is identified as a recurring arrangement created to solve some generalized problem. It is simply a solution outline. That solution outline can be used over and over … Read more

Stack-Walking API – Java 9

A stack trace is a list of method calls arranged in such a way that the method at which an exception was thrown will be at the top followed by the caller to that method and so on till the main method of the program. We can print a stack trace to the console by … Read more