Image for post
Image for post
Photo by Ferenc Almasi on Unsplash

React is an open-source javascript library for building user interfaces. It allows us to create reusable UI components. Before diving into how to make components efficient it will be useful to take a step back and understand how React works under the hood.

Every class component in React has a render() method and every functional component returns a JSX element. It might seem like these methods are responsible for making direct updates to the DOM. However, this is not how it works!

React does not change the DOM directly with every render. It first generates a virtual DOM in pure javascript. It keeps two copies of this virtual DOM, the old virtual DOM, and then re-rendered virtual DOM which gets created when the render() is called. It then compares the old virtual DOM to the re-rendered virtual DOM. If any difference is detected, it reaches out to the real DOM and updates it. However, it does not re-render the entire real DOM. It only changes it in the places where the differences were detected. If no differences are found, it does not touch the real DOM. This process is faster than directly rendering the new DOM to the browser every time since accessing the real DOM is very slow. …


Image for post
Image for post
Photo by Caspar Camille Rubin on Unsplash

In JavaScript, the execution context is the environment that a function executes in. All execution contexts have a creation phase and an execution phase. In the creation phase, it creates this object binding.

this in JavaScript is the object that the function is the property of”

Let us look at the below code snippet and try to make sense of the above statement:

const person = {
name: "John",
speak() {
return "I am " + this.name;
}
}
person.speak()

In the above snippet, what do you think would be the value of this? The object that the function speak() is a property of is person which would hence be the value of this. …


Image for post
Image for post
Photo by Vojtech Ruzicka

Execution context, in simple words, is the environment that a function executes in. Every function in javascript has its own execution context. All execution contexts have a creation phase and an execution phase.

In the creation phase, the execution context exhibits a behavior called hoisting. Hoisting is the behavior of moving all the declarations at the top of the scope before code execution which happens in the execution phase. The javascript engine goes through the code and looks for all “var”s and “function”s and declares them, initializing to undefined, before actually starting to execute the statements. …


Image for post
Image for post

Singleton Design Pattern is a creational design pattern used when only a single instance of a class or struct should exist. The lone instance is called the singleton object.

To demonstrate the design pattern in Golang, let's take the example of a pub/sub client where only one instance of the client should be created and it should be used throughout the application. Below is the code to create the pub/sub client.

package analyticsimport(
"sync"
"log"
"context"
"cloud.google.com/go/pubsub"
)
var lock sync.Mutex
var instance *pubsub.Client
func createPubSubClient() (*pubsub.Client, error) {
if instance == nil {
lock.Lock()
defer lock.Unlock()
if instance == nil {
newClient, err := pubsub.NewClient(context.Background(), GCP_PROJECT_ID)
if err != nil {
log.Fatal(err) …


Image for post
Image for post

Google’s Go language or alternatively Golang is currently one of the fastest-growing programming languages in the software industry. Its speed, simplicity, and reliability make it the perfect choice for all kinds of developers. If you want to get started with a new project using Golang, the following resources will help you get off the ground in no time:

  1. The most commonly used project structure for a medium to large-sized project: https://github.com/golang-standards/project-layout
    A good baseline project to get you started: https://github.com/jasonrey/simple-go-server
  2. Install Go on your system, setting up environment variables, understand root/workspace directories: https://medium.com/rungo/working-in-go-workspace-3b0576e0534a
  3. Setup the configuration files and create the script for server startup: This resource loads the config files at the application start only once. It is also a good repository to help you set up route registrations and the server start-up: https://github.com/jasonrey/simple-go-server/blob/master/pkg/helpers/config.go


Image for post
Image for post

The Object Pool Design Pattern is a creational design pattern in which a pool of objects is initialized and created beforehand and kept in a pool. A client can request an object from the pool, use it, and return it to the pool as an when needed. The object in the pool is never destroyed. This design pattern offers a mechanism to reuse objects that are expensive to create like in the case of creating connections with Redis or a DB. The cost to create each connection object is high due to the network calls involved. …


Image for post
Image for post
Source: Donald Yip / shutterstock

Moving to a foreign country is one of the biggest life transitions you can ever make. While it can be challenging and fraught with paperwork, it can also be an immensely rewarding and enriching experience. About a year ago, I made a difficult decision of moving from San Francisco to Kuala Lumpur and I want to share with you if it was worth it.

I moved from Mumbai, India to Salt Lake City, Utah in 2015 to pursue Masters. After my graduation in 2017, I moved to San Francisco for work. I fell in love with the vibe of the city. I loved my job and my colleagues. I was grateful for everything I had and didn’t have much to complain about. But slowly, I started to miss my family who was still in India in an opposite time zone. When I was not working, I tried to keep myself occupied by working out and catching up with friends. …


Image for post
Image for post

Candidates have traditionally viewed interviews as an unpleasant and stressful experience. However, interactions during an interview are a clear way for a company and a candidate to see for themselves if they fit with each other. We think interviews can be a positive experience. In order to learn about the process and what's expected from a candidate, I will share my approach and describe in detail what’s it like to interview at AirAsia.

The Interview Process might differ a little based on the position you are applying for in the engineering department, but the following steps are common for all:

  1. Recruiter Call: During this initial call with a recruiter, you’ll learn more details about the role and your interview process. Be sure to ask any questions you might have. …


Patriarchy is deep-rooted in Indian society and it has affected my life to a great extent. I was not exposed to the real world until I left home for college. I opened my first bank account in person when I was 18. My hostel life failed to provide me (and all the other girls living on campus), the exposure required to develop the life skills needed to be successful in the real world. The curfew time for girls was too restrictive and the list of “what not to wear on campus” too long. This restricted way of life undermined my confidence and personality. As a result, when I graduated I was not as prepared as my male batch mates, who were way more confident and had seen the world more than me. …


Patriarchy is deep-rooted in Indian society and it has affected my life to a great extent. I was not exposed to the real world until I left home for college. My hostel life failed to provide me (and all the other girls living on campus), the exposure required to develop the life skills needed to be successful in the real world. The curfew time for girls was too restrictive and the list of “what not to wear on campus” too long. This restricted way of life undermined my confidence and personality. As a result, when I graduated I was not as prepared as my male batch mates, who were way more confident and had seen the world more than me. …

About

Anushree Singh

Software Engineer at AirAsia

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