DEV Community

Discussion on: 150+ Typescript one-liners [code snippets].

 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Hahaha gosh it's the first time I read anyone mentioning this in this community.

While this could be a good approach (it is mentioned in my comment before about defensive programming on a different way if you check the link) if the language itself is not applying this "way to work" it will eventually fail (mostly by human error, like the major part if not all bugs we encounter).

It has nothing to do with FP and it's more about the implementation of a given language and how you code with it.

I like defensive programming a lot, still I'm mainly a JS dev (since some years ago) and I'm aware that the language is not implemented like Elm. I'm also aware that I've juniors in the team I manage on almost every project and I need to set up realistic boundaries for them to code in.

Even you code in that way, you can face an error pretty easily when dealing with the own language API as the pre-defined methods of the language will throw errors for sure that, if not controlled, will break your software in runtime.

It is what it is, not what we would like to have 🤷‍♂️😅😂