As per the official documentation of the java collection framework, the collection framework is an architecture that provides facilities to store and manipulate a group of objects. This allows the user to perform the basic functionalities on data such as searching, sorting, deletion, insertion, etc. Here, all the classes, interfaces that are defined for the collection framework are inside java.util package. The following figure 1 illustrates the hierarchy of the collection framework in java.
Before we talk about the design patterns for microservices we need to understand the basic key features which have been contributed to building the microservices architecture. Here I will discuss some of the design patterns currently used by the developers to build microservices.
This can be applied in 3 different ways such as parallel, chained, and branch pattern.
Let’s understand each by using the following example.
Assume there exist 3 services such as student registration, exams, courses allocation, and suppose a consumer called the student management system consumes all these 3 services. Suppose the student registration service sends…
Early and nowadays developers use monolithic architecture to build their web-based applications. But there are some pros and cons related to this. Assume you want to change a small business logic according to a new business requirement. So, you need to put down the entire application for some time to integrate the new requirement into the web application. Assume when developers are working on a large project, they have to maintain a huge codebase. When some problem happens at the production, it is hard to find the place where the problem occurred. Because of that, the developers have to go…
Early days, developers used 2 separate physical servers such as web and application to deploy their web applications. But here, all memory and other features may not be used totally which implies this is not 100% utilizable. As a solution for this hypervisors were introduced.
Web Application Deployment with Hypervisor
A hypervisor or a Virtual Machine Monitor (VMM) allows one hardware to host multiple virtual machines by sharing the common hardware resources such as memory, processing power, etc. Mainly there are 2 types of hypervisors called type 1 and type 2.
Usually, the let keyword is only visible inside the block. Refer to the following code.
Index is: 0
Index is: 1
Index is: 2
Index is: 3
Index is: 4
^ReferenceError: temp is not defined
The memento design pattern allows to undo or restore the previous version of the object. This is categorized under the behavioral pattern. As per the book written by the gang of four (GOF), there are 3 pillars in the memento pattern called originator, memento, and the caretaker.
Let’s understand this using a real-world scenario.
Assume, a certain company provides rewards to their…
The chain of responsibility pattern can be applied when we need to apply the loosely-coupling concept in our work. This is categorized under the behavioral pattern.
Let’s understand the way of applying this pattern using a real-world example.
Assume, a certain company calculates the salary of each employee for a specific month as, if the working hours of a certain employee lie between 180 hours and 200 hours, 30% of the base is added to the base salary. …
The builder pattern comes under the creational design pattern.
When we have multiple variables inside the class, we have to create instances of this by including more than one parameter at a time. In such cases, we can implement the constructors manually, but it is hard and time-consuming. As a solution for that, we can create multiple constructors by using the telescope method. But, here also due to passing null values, etc., has to handle each scenario (NullPointerExceptions) manually. Instead of using constructors, we can use setters to assign values to the variables declared inside the class, but here, mutability…
The prototype design pattern is responsible for creating new objects without using the new keyword and this allows cloning the previously created objects. This is categorized under the creational pattern. The prototype design pattern is used when the creation of objects directly is very costly or expensive.
When we implement the prototype pattern we must be aware of whether we need a shallow copy or a deep copy of the object.
This implies the cloned object is just simply a copy of the exact resource.
Here we need to copy everything inside the object into the…
Factory method design pattern comes under the creational pattern and this allows the user to create objects without exposing the creational logic.
Usually, here we use parameters to create instances because this returns the objects based on the parameters we pass. The returned object might be a subclass, class with an implemented interface, extended class of an abstract class, etc.
The following describes how we can implement the factory method design pattern using a real-world example in java.
Assume, a certain company has a particular salary schema as;
The salary of the month is calculated based on the experience…
Associate Software Engineer, Undergraduate BSc (Hons) in Computer Science