Get the latest tech news

Use Your Type System


Today I'm discussing a trivially simple technique that I've rarely seen used in production codebases. In programming, we often need to deal with simple values that can be represented by simple, generic types built into our programming language or provided by libraries: types like integer, string, or UUID. In any

In any nontrivial codebase, this inevitably leads to bugs when, for example, a string representing a user ID gets used as an account ID, or when a critical function accepts three integer arguments and someone mixes up the correct order when calling it. int or string are excellent building blocks, but passing them around your system as-is means you slowly but inevitably lose important context: what they actually represent. I've seen so many bugs in real systems due to mixing up integers, strings, or UUIDs that represent different things.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of type system

type system

Related news:

News photo

A type system for RCL, part 2: The type system