Change is unavoidable. Photo by Daria Shevtsova from Pexels

An enumeration type in a programming language (“enum”) is a set of named values. The name of an enum and the names of the values thus have significant meaning. So much so, that the names are the reason for their existence!

The first thing to note is that enums are compile-time constants. And, because of this, they don’t respond well to change — they weren’t meant to. Any place where we switch on cases of enumeration values is not extensible by design. But, if you’re using enumerations in a rapidly evolving application, the normal rules don’t apply. …

Risk (Edited from photo by Elianne Dipp from Pexels)

A little while ago, I was working on a change in a typescript-react app with a colleague. We ended up making a breaking change to a major feature, and — as a result — had to update all the usages as well. In one such update, we now had to use a numeric entity id that was present in the url. We used react-router with url params, and react hooks, and the code I wrote went something like this:

And as soon as I wrote this, they had a question for me:

Why not use Number?

Understanding the difference

Let’s dig into…

That’s how awesome I feel when I write tests in TypeScript

TypeScript has gotten so much better in the last year, and so many new applications and projects are built on top its awesomeness. Its first-class integration and support in Visual Studio Code helps a lot, and I think TypeScript as a language is here to stay, despite some people having their misgivings.

The usual process is to write code in TypeScript, and have it compiled to JavaScript, and then served to the browser as a JavaScript file. We usually only have to test the JavaScript files that are emitted by the TypeScript compiler. But wouldn’t it be so much easier…

Being single and behaving responsibly. Again.

The Single Responsibility Principle, sometimes referred to as SRP, is the first of the five SOLID principles. In our last post we introduced the idea of a module, and how having only a single responsibility for each module makes the modules, and thereby our system, more robust. We touched upon the idea that single responsibility transcends modular levels. We will be going over this concept in detail, and then round up our understanding of SRP in this post.

Just to summarize what we covered in the previous post, modules are units of code that are reusable, compose-able, and obey a…

Being single and behaving responsibly.

Almost every techie I come across who has worked with writing object oriented code, seems to be proud that they write SOLID code. Not solid, in the sense that the code is stable, but rather SOLID, as in applying the five basic principles. The other day I asked a person how a piece of code followed the Liskov Substitution Principle (the L in SOLID), and they couldn’t really reason it out. And they had just boasted about having written SOLID code all long. And I just thought, maybe, just maybe, I could do something to clear some of this stuff…

The number of darts is coincidental. No, really.

This is my last post of the year. And I’m making a wish list of sorts. A new year resolution, if I may. Staying true to the theme of the publication, this is a plan for the journey ahead in the forthcoming year.

Write code daily

Work-related code doesn’t count. Does not need to be open source.

Part of my work involves writing code, and even aside from that, I enjoy writing code. And I want to get better at it. And what better way to improve, than to do it daily? Every day, apart from work, I will write some code. …

Here’s a little secret: everybody has something to offer.

A couple of months ago, no one would’ve believed that I could write a post with this title — and get away with it. But now I’m sure many will appreciate that I took the time to write a post like this. This isn’t a personality development post. But it does have some takeaways — especially for any developer/designer on a journey, like myself.

Coming to think of it, the title seems to be in reverse: it should’ve been How not to alienate people abruptly, and risk losing everything they have to offer: Don’t be a jerk. Because, really, it’s…

UPDATE: There’s a newer version of this post, with more details and solutions. It’s advisable to head there instead. The contents of this post may be outdated and the solutions posted here may no longer work.

TypeScript is something I’m crazy about, and I recently started a project in TypeScript which needed tests. In this post, I explain how to set up a simple setup where we can have our tests also written in TypeScript, wherein we can use our TypeScript import syntax, and have type inference helping with whatever we do.

We have a lot of tools and frameworks…

In a previous post, we were introduced to the Recall app that was built with Cycle.js. A couple of people were interested to know how to break an app down into its components. Towards this, in this post, let’s take a look at a few ways to make simple changes to the Recall app that make it more modular, in the sense that it works with a lot of components working together, rather than a single app with lots of logic.

Recall — A little context

A sample to anatomize solutions over

In case Recall as an app is not something you’re familiar with, a…

Over the last two weeks I had the wonderful opportunity of organizing and giving a talk at a dev event. I jumped at it, I’ve always wanted to do something like that. Four of us quickly teamed up to organize things, but the event was carried by each and every one at Sahaj. I’m currently beaming with pride: I was a part of a team that had made the best of the opportunity — we were able to bring in a wonderfully inquisitive crowd of 30 people. At our first event.

And we’re just getting started.

NOTE: This is a…

Sudarsan Balaji

I have fun solving problems I like, and love getting better at it.

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