String: Why it is Immutable?

Why String is Immutable?
This is one of the most popular interview questions. In this blog, we are going to talk about it and find the answer. String is one of the most used Class in any Application. For storing the username, password, address, IP address etc, we need to create String objects. So it is necessary to understand why our most famous and used Class is Immutable.

First of all let’s see what Immutable means:

Continue reading “String: Why it is Immutable?”

An Introduction to HBase

In our last two blogs, we talked about the HDFS Cluster & Zookeeper Cluster. Which is needed for deploying OpenTSDB in clustered mode. Continuing to the series, In this blog, we are going to talk about HBase which will be used by OpenTSDB in the cluster to store data.

HBase is a column-oriented NoSQL database management system that runs on top of Hadoop Distributed File System (HDFS).

Continue reading “An Introduction to HBase”

Redis : A Caching Database

Redis_Logo.svg

Redis stands for Remote Dictionary Server. It is opensource, in-memory key value data strucure store, which is extremely fast. In other words, it can also called as caching no sql database.
So, Redis is no sql database which can be used as a cache or message broker. The data structure supported by it are lists, hashes, strings, sets, sorted sorts with range queries, bitmaps, hyperloglogs and geo spatial indexes with radius queries. It has built in replication, Lua scripting, LRU eviction, transcations and different levels of one-disk persistence. It also provides high availiblity via Redis Sentinel and automatic partitioning with Redis cluster.

Continue reading “Redis : A Caching Database”

Callable & Future in simple words

Sometimes we have to run a long-running task in a separate thread and return the result once execution is complete. Using Java Runnable interface we can run a task, but the disadvantage is it does not return result once execution is complete.

Then how can we achieve this?

There are two interfaces available in java.util.concurrent package using them we can solve this problem.

Continue reading “Callable & Future in simple words”

Facade Design Pattern

Facade Design Pattern is the Structural design patterns (like Adapter pattern and Decorator pattern). Facade design pattern is used to easily interact with the complex system.

According to Design Patterns: Elements of Reusable Object-Oriented Software (Gang of Four) Facade design pattern is:

Provide a unified interface to a set of interfaces in a subsystem. Facade Pattern defines a higher-level interface that makes the subsystem easier to use.

Continue reading “Facade Design Pattern”

DECORATOR DESIGN PATTERN

Let’s imagine we want to create a game, and for our superhero, we want to add a new gadget to every level of the game and gadget should be selected by the player.

How we can do that?🤔

One way to do that use traditional inheritance, We will create a base abstract gadget class and multiple subclasses for different gadget combination.

But wait I have n numbers of gadgets so in my case I have to create n! subclasses.

If n = 5 then for 5 powers the number of subclasses will be 5! = 120. For 5 gadget we have to create 120 subclasses.😢

Is there any other simple way to do that?

Yes, We can use Decorator Design Pattern to solve this problem.

Decorator Design Pattern allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class

Continue reading “DECORATOR DESIGN PATTERN”

JAVA EE to JAKARTA EE

The acquisition of Sun Microsystems by Oracle Corporation was completed on January 27, 2010, and became the owners of Java.

In September 2017, Oracle gave up on Java Enterprise Edition (JEE), aka J2EE, to The Eclipse Foundation. On February 2018, The open source version of Java Enterprise Edition (Java EE) has been renamed Jakarta EE to satisfy Oracle’s desire to control the “Java” brand.

Continue reading “JAVA EE to JAKARTA EE”

JAVA: Schedule Task in Java

Many times we have to write some set of task which can be executed after a certain interval of time. These types of task are called timer task.

So we can achieve it by using threads which will sleep for a certain amount of time and execute again. But wait, Can Java do this for me So that I can focus on logic instead of worrying about how to schedule tasks for me?

Yes, Java can do the scheduling thing for you. So you write your logic and let Java handle the scheduling work.

Continue reading “JAVA: Schedule Task in Java”

Java: Garbage Collection

When someone asks me “Tell me one thing you likes about java?” and my answer is short and simple “Garbage Collection” .

What is Garbage Collection:

 As JVM memory is limited, you need to remove unused objects, so your application have enough memory to perform it task. Garbage collection is the process of removing unused objects from heap memory.  

Continue reading “Java: Garbage Collection”