4 ms·
I've also seen it called primitive obsession, which is also applicable to other primitive types like using an integer in situations where an enum would be bette
by zeroCalories 3y ago
I've also seen it called primitive obsession, which is also applicable to other primitive types like using an integer in situations where an enum would be better.
- skitter 3y agoSadly enums are too advanced of a concept to be included in Go.
- eru 3y agoSee https://eli.thegreenplace.net/2018/go-and-algebraic-data-types/ https://eli.thegreenplace.net/2018/go-and-algebraic-data-typ... for more background.
- fbdab103 3y agoDefinitely use to fall for primitive obsession. It seemed so silly to wrap objects in an intermediary type. After playing with Rust, I changed my tune. The type system just forces you into the correct path, that a lot of code became boring because you no longer had to second guess what-if scenarios.
- xboxnolifes 3y ago> Definitely use to fall for primitive obsession. It seemed so silly to wrap objects in an intermediary type. A lot of languages certainly don't make it easy. You shouldn't have to make a Username struct/class with a string field to have a typed username. You should be able to declare a type Username which is just a string under the hood, but with different associated functions.
- deleted 3y ago[deleted]
- nogridbag 3y agoWe use this pattern extensively in a large Java app. As long as you establish these patterns early on in the project, the team adapts to the conventions. It's worked well for us and the lack of language support doesn't get in the way much.
- zeroCalories 3y agoYeah, modern type systems are game changers. I've soured on Rust, but if Go had the full Ocaml type system with match statements I think it would be the perfect language.
- kaba0 3y agoGo would need such a revamp to be anywhere close to a decent language, that it would be just a straight up other language.