Liskov Substitution Principle explained with simple example

Liskov Substitution Principle (LSP) is a software design principle which states that “derived class objects should be completely replaceable by their base classes“. This principle ensures that any derived class extending base class will not change their behaviour.

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

(more…)
Liskov Substitution Principle explained with simple example Read More

Open/Closed design principle explained with simple example

Open/Closed design principle is a software design principle which states that every module, class or function of a software should be open for extension but closed for modification. This design principle ensures any new functionality can be added via new classes which means minimum code changes required in existing classes.

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

(more…)
Open/Closed design principle explained with simple example Read More

Single Responsibility Principle explained with simple example

Single Responsibility Principle (SRP) is a software design principle which states that every module, class or function of a software should have one and only one responsiblity/functionality to perform. As stated by Robert C.Martin, “A class should have one and only one reason to change“.

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

(more…)
Single Responsibility Principle explained with simple example Read More

Software design principle explained with simple example

Software design principle consists a set of guidelines invented by Robert C.Martin to avoid bad software design. These guidelines consists of five design principles for object oriented software development. These design principles are:

Together these are called SOLID design principles.

(more…)
Software design principle explained with simple example Read More

Why do we need Software Design Principles

Object oriented software development often becomes victim of non-maintainable, unreliable etc in long run in most of cases. Lot of people might put bad coding skills behind that state (which is true sometime) but bad software design is the actual culprit which will make excellent coders write bad code because software design doesn’t allow them to do so.


Always remember knowing what not to do is more important than what to do !!!

(more…)
Why do we need Software Design Principles Read More

Merge sort explained with simple example

Merge sort is one of the simplest sorting algorithm, which works on Divide and Conquer algorithm. In this sorting algorithm, input data is divided into two halves/sublist which then acts as input data and furthur divided into two halves so that finally every sublist contains a single element. Finally, these sublists are merged in sorted order which results into sorted data.

Pros:
1) Simple algorithm and hence efficient for small list of data.
2) Good for sorting data represented in Linked list.
3) This algorithm is stable (performance is equal in all cases) and insensitive to the distribution of initial data.

Cons:
1) Extra space needed in O(n).

(more…)

Merge sort explained with simple example Read More

Selection sort explained with simple example

Selection sort is one of the simplest sorting algorithm, which traverse through the list, picks the minimum item from the unsorted list and place it in its place in the final sorted list.
This sorting algorithm contains (n – 1) traversal.

Pros:
1) Simple algorithm and hence efficient for small list of data.
2) No extra memory needed.
3) Good for cases when list is almost sorted (only few misplaced items).
4) Very less number of swap operation(O(n)), as in every pass only 1 swap of data is needed at max.

Cons:
1) Very slow algorithm. Not good for very large set of data.

(more…)

Selection sort explained with simple example Read More

Insertion sort explained with simple example

Insertion sort is one of simplest sorting algorithm which traverse through the list, picking one item at a time and place it in its place in the final sorted list. This sorting algorithm contains (n – 1) traversal.

Pros:
1) Simple algorithm and hence efficient for small list of data.
2) No extra memory needed.
3) Good for cases when list is almost sorted (only few misplaced items).

Cons:
1) Very slow algorithm. Not good for very large set of data.

(more…)

Insertion sort explained with simple example Read More

Bubble sort explained with simple example

Bubble sort is one of the simplest sorting algorithm which traverse through the list, compares items at adjacent places, and swaps them to make list sorted. After every pass of list one or more item is placed at its correct position. If in a pass, no swaps are performed then it means list becomes sorted.

Pros:
1) Simple algorithm.
2) No extra memory needed.
3) Good for cases when list is almost sorted (only few misplaced items).

Cons:
1) Very slow algorithm. Not good for very large set of data.

(more…)

Bubble sort explained with simple example Read More

Sorting algorithms explained in simple manner

Sorting is an operation in computer science via which data is being arranged in an ordered sequence. There are lots of efficient algorithms are already present to perform sorting operation which we are going to discuss here.

Some of the most used sorting algorithms are as follows:

1) Bubble Sort
2) Insertion Sort
3) Merge Sort
4) Selection Sort
5) Quick Sort
6) Heap Sort

Comparison of various Sorting algorithms in terms of time complexity for best and worst case:

(more…)

Sorting algorithms explained in simple manner Read More