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”