6 ms·
> But the main problem for me is the cost is too high for such little benefit. Understanding and maintaining a type system like that is hard. You are not going
by Jtsummers 5y ago
> But the main problem for me is the cost is too high for such little benefit. Understanding and maintaining a type system like that is hard. You are not going to eliminate all bugs. Wouldn't the effort be better spent on writing more tests? I feel like developers prefer creating more types over writing more tests because it's easier, though.
It's not that types are "easier", it's that they give you things that tests either can't provide or don't provide without serious discipline (often lacking in general, but even when present it's easy to let things slip through).
The thing to aim for is both. Since, short of dependently typed languages, it's practically impossible to encode everything into the type system, tests will remain. But types allow you to express things that become tedious in tests and get the same at least as many guarantees as a comprehensively tested code base but without the same dependency on discipline, which doesn't scale.
> This contradicts the Universal part of UUID. If they're not the same then why use UUID at all?
UUID = Universally Unique Identifier. Not "Universal", "Universally". That extra bit is important, it's qualifying the "Unique" part and not the "Identifier" part. But, importantly in the context of the article, UUIDs could refer to different "types" of things (users, inventory items, addresses, transactions, etc.). By adding a shallow (in this case) wrapper around it it prevents trying to do something like receive a User ID (as a UUID) and trying to find it in the inventory database (using the same UUID value).