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

Pseudomandatory parameters in es6 functions

In many programming languages, the parameters of a function are by default mandatory and the developer has to explicitly define that a parameter is optional. In Javascript, every parameter is optional, but we can enforce this behavior without messing with the actual body of a function, taking advantage of es6’s feature of default values for parameters.

const _err = function(message) {
  throw new Error(message);

const getSum = (a = _err('a is not defined'), b = _err('b is not defined')) => a + b;

getSum(10); // throws Error b is not defined

`_err` is a function that immediately throws an Error. If no value is passed for one of the parameters, the default value is going to be used, `err` will be called and an Error will be thrown. You can see more examples for the default parameters feature on Mozilla’s Developer Network.