Code Tips #3: Remove argument-order dependency and provide defaults

Argument order in function signature is a common source of bugs and frustration. Imagine you have the following Vehicle class, its constructor accepts values to instantiate an object. Passing the values in the wrong order can easily lead to bugs that are not so easy to catch.

class Vehicle {
  constructor(speed, weight, power, color, brand){
    this.speed = speed;
    this.weight = weight;
    this.power = power;
    this.color = color;
    this.brand = brand;
  }
}

Continue reading Code Tips #3: Remove argument-order dependency and provide defaults

Code Tip #2: Isolate References to external classes

Imagine we have the following Vehicle class that has a dependency on the speed property of an Engine class.

class Engine {
  constructor(speed){
    this.speed = speed * 1.2;
  }
}

The Engine class accept a speed value and uses a factor to define the final speed. Its internals is not so important. Continue reading Code Tip #2: Isolate References to external classes

Code Tips #1: Hide Dependency to a Data Structure

Many times we encounter situations where our code depends on a complicated data structure or a data structure that has implicit semantics. For example, let’s say we create a chart and the data that we have to use is a response from a server (we can’t change the structure of the response). The response from the server looks like this:

[
 ["2018-12-02", 1000], 
 ["2018-11-02", 900], 
 ["2018-10-02", 200], 
 ["2018-09-02", 300]
]

This structure has an implicit meaning, it is an array of arrays, each of which has two values, the first represents a date and the second one a value. The naive approach is to Continue reading Code Tips #1: Hide Dependency to a Data Structure

Implementing backpressure for smoother user experience in low-end devices

If you are building applications that consume real-time data you may have faced a situation where the component or service that consumes the data cannot keep up with the volume or speed of the produced data. The “producer” module of the system is emitting data faster than the “consumer” module of the system can process.

The consumer tries to keep up processing the data by increasing the amount of the system resources it is using (CPU, memory), that can be fair in Continue reading Implementing backpressure for smoother user experience in low-end devices

Provide i18n to an application without harming its performance

Internationalization/Localization is an important aspect of a successful web application and one that can be particularly difficult to get it right from the beginning.

In React world there are several i18n solutions, with react-i18n by Yahoo being the most popular one. Its use is pretty simple, you just wrap your application with Continue reading Provide i18n to an application without harming its performance

Rage against flexibility

Often while I am reviewing code I stumble upon pieces that are trying to do way more things than the requested feature demands. We all have been there, either reading or writing code that does more things than the ticket/issue we are working on requires. Many times we try to predict the future, because we guess that touching this specific part of the system now is easier than doing it later when a new requirement comes up. In my opinion this mentality is completely wrong and can lead to slowing down a team instead of moving things faster.

Let’s image that your boss asks you to create a component that accepts an array and renders a list of items, and you guess Continue reading Rage against flexibility

Abstract class in Javascript

Many object orientated language offer the notion of an abstract class.

An abstract class is, conceptually, a class that cannot be instantiated and is usually implemented as a class that has one or more pure virtual (abstract) functions. (source: wikipedia)

 

In C++ for example:

 

Java has also the concept of Continue reading Abstract class in Javascript

Book Review: Front-End Reactive Architectures: Explore the Future of the Front-End Using Reactive JavaScript Frameworks and Libraries

(2 / 5)

I had high expectations, but this book doesn’t really cover the topic in depth, its more or less a list of reactive libraries and frameworks. If you want to learn more about the topic its probably better to read related papers, or what’s the talks about RX on youtube.