Hacker News new | ask | show | jobs
by tossandthrow 37 days ago
I have had this conversation with the team. I lead, who started to use properties of the ID for ordering etc.

An ID is an identifiers. It supports exactly the operation of comparing two IDs to establish identity.

When you start to treat them as something else that is not guaranteed, you will see weird things happening.

1 comments

You can encode extra things in IDs no problem. E.g. Polish civil records system uses PESEL numbers which, on top of being unique IDs, also encode date of birth and gender.

As long as you have absolute control over every single ID generated, it will work just fine. The problem is that it's way too easy to accidentally generate UUID in a way that ignores whatever rules you set up for it. Also, clocks are hard.

As long as these are not accidental invariants.
As long as they are invariants. Due to clerical errors, the aforementioned PESEL numbers are not really unique and the gender doesn't always match records and even the checksum digit is sometimes incorrect. And the encoded date of birth isn't always the actual date of birth, but this one is intentional (there's only 5000 numbers available for each day, per gender).