Mediator Design Pattern explained with simple example

Mediator design pattern basically defines an interface class which provides a mechanism for providing communication between various modules/components of the software. Since, mediator needs to access each component of the software, which means it should be added as a reference in each component. Using this mediator class components becomes less dependent on each other which means coupling is reduced.

Before going ahead have a look at Design pattern simplified version.

(more…)
Mediator Design Pattern explained with simple example Read More

Iterator Design Pattern explained with simple example

An iterator is an object which allows a developer to easily traverse through a container class. The Iterator design pattern is relatively simple and easy to implement kind of design pattern in which an iterator is used to traverse through a complex container in order to access the elements of the container. This design pattern tries to decouple container classes from the other modules in order to achieve low coupling.

Before going ahead, have a look at Design pattern simplified version.

(more…)
Iterator Design Pattern explained with simple example Read More

Print longest common subsequence string of two string

The longest subsequence problem (LCS) is the problem in which we need to find the longest subsequence present in two sequences. In this case, characters doesn’t require to be in consecutive places.

For eg:

LCS for sequence “ABCDFG” and “ABCGDFG” is “ABCDFG” and its length is 6.

For calculating longest common subsequence length we can use recursion or dynamic programming, here we are going to see how to find the longest common subsequence string.

(more…)
Print longest common subsequence string of two string Read More

Longest common subsequence problem using dynamic programming

This problem can be solved using multiple approaches but here we will solve this problem using Dynamic Programming and showcase how dynamic programming will make the execution super-fast.

We will go through with the same steps as mentioned in Dynamic Programming post to tackle this problem step by step for better understanding.

Let’s explain the problem,

The longest subsequence problem (LCS) is the problem in which we need to find the longest subsequence present in two sequences. In this case, characters doesn’t require to be in consecutive places.

For eg:

LCS for sequence “ABCDFG” and “ABCGDFG” is “ABCDFG” and its length is 6.

Let’s apply the 3 Steps rule (Dynamic Programming) to tackle this problem.

(more…)

Longest common subsequence problem using dynamic programming Read More

Converting Roman number to Decimal using Interpreter design pattern

Interpreter design pattern is mainly used in compiler and other language processing programs. This design pattern used to identify various language mainly textual such as numbers, regular expression etc. This design pattern interprets every language syntax and assign a class accordingly, to do further processing.

Before going ahead have a look at Design pattern simplified version.

(more…)
Converting Roman number to Decimal using Interpreter design pattern Read More

Interpreter Design Pattern explained with simple example

Interpreter design pattern is mainly used in compiler and other language processing programs. This design pattern used to identify various language mainly textual such as numbers, regular expression etc. This design pattern interprets every language syntax and assign a class accordingly, to do further processing.

Before going ahead have a look at Design pattern simplified version.

(more…)
Interpreter Design Pattern explained with simple example Read More

Monostate Design Pattern explained with simple example

Monostate design pattern is a singleton design pattern variation in which a class will act like a singleton but this class will look like a normal class. This design pattern states that all data member of monostate classes are static but any number of instances can be created in the program.

Before going ahead have a look at Design pattern simplified version and Singleton design pattern.

(more…)
Monostate Design Pattern explained with simple example Read More

Dependency Inversion Principle explained with simple example

Dependency Inversion Principle (DIP) is a software design principle which states that “High-level modules should not depend on low-level modules. Both should depend on abstractions And Abstractions should not depend on details. Details should depend on abstractions“. This design principle ensures a lower coupling between different classes.

Before going ahead we should know why do we need software design principle and what is software design principle.

(more…)
Dependency Inversion Principle explained with simple example Read More

Interface Segregation Principle explained with simple example

Interface Segregation Principle (ISP) is a software design principle which states that “many client specific interfaces are better than one generic interface“. This principle enforces to implement only usable methods which will reduce coupling between modules. This principle ensures that any client should be dependent only on those methods which they use.

Before going ahead we should know why do we need software design principle and what is software design principle.

(more…)
Interface Segregation Principle explained with simple example Read More