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.

Image for post
Image for post

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.

Image for post
Image for post

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 !


Image for post
Image for post

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.

Major problem with Python

Python is slow ! There are competitors of Python which are open source and they are gaining popularity already… and the sole reason for that is that those programming languages are very very fast. …


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

Image for post
Image for post

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 the add() method in Java APIs i.e. rt.jar , you will find the following code in…

About

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