An Introduction to the Collection Framework in Java

Overview

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.


Design Patterns for Microservice Architecture

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.

Aggregator Pattern

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…


An Introduction Microservices and Their Best Practices

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…


An Introduction to Dockers and Containers

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.


Things You Must Know About the Modern JavaScript

Overview

JavaScript or JS is a multi-paradigm language and this supports both object-oriented and functional programming. This was improved and released several editions after the first release. JavaScript holds different data types such as;

  • Number
  • BigInt
  • String
  • Boolean
  • Symbol
  • Object (Function, Array, Date, RegExp)
  • null
  • undefined

Modern JavaScript

Here define some of the key improvements involved in modern JavaScript.

Let

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
console.log("'Length: "+temp);
^
ReferenceError: temp is not defined

But…


An Introduction to Memento Design Pattern

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.

  1. Originator: This creates the memento object and this is the original object that the state needs to be saved.
  2. Memento: This is responsible for storing the internal state of the originator.
  3. Caretaker: This keeps track of the mementos.

Let’s understand this using a real-world scenario.

Assume, a certain company provides rewards to their…


An Introduction to Chain of Responsibility Design Pattern

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


An Introduction to Builder Pattern

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…


An Introduction to Prototype Design Pattern

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.

Shallow Copy

This implies the cloned object is just simply a copy of the exact resource.

Deep Copy

Here we need to copy everything inside the object into the…


An Introduction to Factory Method Design Pattern

Overview

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…

Hasini Sandunika Silva

Final year undergraduate in Computer Science, Associate Software Engineer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store