The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Ok…enough of pedagogy !!! Lets make it simple now using a use case.

Strategy Design Pattern leverages these 3 design principles heavily:

  1. Identify the aspects of your application that vary and separate them from what stays the same
  2. Program to an interface, not an implementation
  3. Favor composition over inheritance

Use Case

Lets say we are developing a Calculator which performs sorting and searching. There are various algorithms using which sorting and searching can be performed. …

JPEG stands for “Joint Photographic Expert Group” and it is a lossy data compression algorithm used to compress digital images. It is good at compressing natural photographs but falls short while compressing vector artworks. In this article we’ll see technical details on how this famous encoding algorithm works.

Why should we compress images? — The simple answer is “to save the space”. Consider an example of 3000X4000 pixel image in RGB color space. If each channel of RGB is 8-bit, the size of this image would be 36MB !

In last few years Python has been one of the most favorite programming language of many developers because of its amazing capabilities which lets us perform multitude of developments including:

  1. Full stack development
  2. Data Science
  3. Machine Learning, Deep learning
  4. Etc.

It has abundant set of libraries which make development very very easy.

The bitter truth- But there is a major problem with Python which can be cause of death of this popular language. This may not happen in short-term (in a year or two), but its inevitable to happen within a decade from now.

Python is slow ! There are…

By definition, each and every element in a set is unique and there are no duplicate elements in it.

But have you ever wondered how JAVA APIs achieve this internally? To know it all, please read on…

Basic Example

Notice how duplicate elements are simply disallowed entry into the set object

When you pass duplicate element in the add() method of the Set object ,it will return false and does not add it to the HashSet since the element is already present.

Lets see how this add() method is implemented internally in Java?

If we open the HashSet implementation of…

Pawan Kishor Singh

Adobe Systems

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