4 ms·
I have created a custom unique identifier scheme before. This post doesn't address some of the challenges you come across. 1. When dealing with user friendly I
by consoomer 3y ago
I have created a custom unique identifier scheme before. This post doesn't address some of the challenges you come across.
1. When dealing with user friendly IDs, it's often important to make sure there are no ambiguous characters. This is a UX requirement for anyone that may need to read an ID and type it in at any point. For example, this means removing certain confusing characters like "0oIi1l5sS", etc. You end up with a much smaller set of characters. In my case, young children were required to type in teacher codes. Needless to say, I had to limit a lot of possible confusing characters.
2. You will have collisions. How do you handle them (ie, retry N times until you get a valid one)? What happens if you can't get a valid one? This happened in a product of mine. We had ~8 character codes that were human readable and type-able and we... ran out of codes.
3. How can you embed more information into the code such as versioning? It's often useful to prefix a code with some info in the event you need to modify it later (such as expand the character set or length)?
- nick_ 3y agoNumber two can be addressed with something like this: https://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/ https://preshing.com/20121224/how-to-generate-a-sequence-of-... You can shrink the range by using a smaller prime number and throwing on out-of-range input. And then you can offset the output to make sure the base-N encoded value is always D digits long.