I thought (var) Gozer was a man. It's whatever it wants to be.

December 23, 2021

Tom Hacohen wrote a great post about his view of types and their place in development. At the end, he asked for different views, and so I thought I would oblige and participate.

Admittedly, my view of types and their necessity has changed over the past couple of years. JavaScript has been the weakly typed/untyped language I’ve used the most. On the other side, I’ve used C#, F#, and TypeScript quite extensively (others too but not worth mentioning). I’ve left the “what is right/wrong” camps to really what works for the situation. I think that strong typing is great and it definitely has a place, but I will say that personally at this time I program a lot in JavaScript, and I have dispensed with needing them to be effective.

No decision comes without a price, and the ultimate question is it worth paying. Types will help in catching certain errors. They do allow developers to cognitively offload the need to validate if the function is going to have any chance behaving correctly when passing it a parameter. The drawback to this is that in order to make functions more generic, objects passed to the function require a binding commonality: interface, inheritance, etc.

    function FormattedPhoneNumber FormatNameAndPhoneNumber (INameAndPhoneNumber nameAndNumber){
        return  $"{nameAndNumber.Name}, {nameAndNumber.phoneNumber}"
    }

In this example it’s possible to avoid the use of a complex type and separate the parts into two parameters.

    function string FormatNameAndPhoneNumber (string name, string phoneNumber){
        return  $"{name}, {phoneNumber}"
    }
← Back to Blog