Sign in

Coder, Amateur Musician, Blogger, Quora writer
Photo by tito pixel on Unsplash

This is the second chapter of Head First Design Patterns book. Though the book has code snippets in Java, my attempt here is to implement the problem discussed in Go. Without further ado, let’s understand the use-case.

The problem statement

We are told to design a weather monitoring application. It consists of 3 sections

  1. Weather station : to record humidity, temperature and pressure
  2. Weather data : tracks data from the weather station and forwards it to the displays
  3. various display elements :
  • current conditions,
  • weather statistics,
  • a simple forecast, and
  • a heat index calculator


Photo by JESHOOTS.COM on Unsplash

Usually I find technical books very dry, but Head First Design Patterns was awash with funny anecdotes and eye-grabbing illustrations. It felt a good place to start learning design patterns though it may miss out on more intricate details. The code examples are in Java. I recently started learning Go and chose it to implement the strategy pattern.

Strategy Pattern

According to the book,

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.

Okay, that did not make much sense to me at first too…


Back when I learnt merge sort, I always saw this diagram of dividing the array till the end and merging them in a sorted manner. A passing thought came to my mind, what if we could run the two halves in parallel like the diagram showed. Found out later like any other inventions, I am too late to the game. But felt content that my hunch was right and it has been attempted.

Classical Merge sort [Photo by Vineet Kumar at English Wikipedia / Public domain]

The algorithm

Let’s take a look into the pseudo-code and understand.

A[p...r] : array p : start of array r : end of array MERGE_SORT(A, p, r) if p…


This will be a basic tutorial to familiarize the concept of state hook.

Photo by Ferenc Almasi on Unsplash

The idea

The mini-application will display videos of four rock bands and ask you to like or dislike the bands accordingly. A list of all your liked bands will be displayed below.

The environment

I always like to make a small snippet of code on codesandbox to try out things as a proof of concept.

Steps

  1. Create an account at codesandbox.
  2. Open the dashboard, and Click on “Create React Sandbox”.
  3. Let the magic happen!

The data

In most of the cases, the data is obtained through an API request. …


Photo by Clément H on Unsplash

In JS, an object is an unordered collection of associated key/value pairs (properties). Each property can reference a primitive type (string, number, boolean, null, undefined) or another object (array, functions, etc).

There are two types of two forms of objects,

  • Literal (Declarative form)
const developer = {
name: 'Srinjoy Santra',
age: 21,
"isGraduate": false
};
  • Constructed form
const developer = new Object();
developer.name = 'Srinjoy Santra';
developer.age = 21;
developer['isGraduate'] = false;

Let’s break these down and see what’s going:

  • The variable that is assigned to the object is named developer.
  • Curly brackets are used to define the developer object.


Photo by Jan Losert on Unsplash

In the month of December last year, an email from Udacity India appeared in my inbox. Given the brand name of Google and Udacity in the technology and education fields respectively, it was a big opportunity ahead. I proceeded to fill up my application without thinking twice, only to be encountered with thought-provoking questions such as why I should I be considered for the scholarship, my interests and my involvement in my other personal goals.


On 28th October 2017, few of my classmates and me formed a team to participate at our first-ever hackathon. Named #OpenGovDataHack, it was one of the most prestigious hackathons of India. The event was concerned with building a mobile application or an infographic based on the data-sets provided by the government of India.

Being second year students we didn’t know enough to compete in the hackathon. We believed that the 24 hour long event would be one hell of an experience, and sure it was. …


Inspired byAutomate the Boring Stuff with Pythonby Al Sweigart , I thought of putting it to some good use for my college based course.

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