3 ms·
You need to think about backwards and forwards compatibility either way, types help make that easier.
by NoahKAndrews 2y ago
You need to think about backwards and forwards compatibility either way, types help make that easier.
- necovek 2y agoNot when they are misused, which is quite common. The example of the article is a great one: replace all your arguments to a function with a single argument of a new "type". Soon, this new type gets used in another function, and it "just" needs another field added. Suddenly, you inadvertently changed the API for the previous function. So yes, you need to worry about backwards and forwards compat either way, but misusing types will make it harder and more error prone. Instead, if you carefully used types only when they really represent a new logical thing, you wouldn't replace unrelated set of arguments with a single argument of a new combo type, and code would be cleaner and saner.