In java, we have UUID (Universally unique identifier) for generating unique IDs.
I am using this to get unique identifiers.
So, I am getting an unique identifier as: 35ffa200-aaa5-40ec-ab6f-20bb36632f86 (5 groups separated by hyphens).
I dont need such lengthy identifiers. My identifier must be of short value, say the code must be of only 3 groups. How can I get such small unique identifiers. Is there any limits in UUID class? I am afraid to use string limits for UUID. Is it a correct way
or is there any way to generate such small unique identifiers?
Thank you.
UUID stands for Universally Unique IDentifier. Most of the bits of a typical UUID are dedicated to the problem of making the identifiers universally unique, both in time and in the “space” of the internet. In fact there are a number of different UUID formats that address this problem in different ways, but they all depend on having a lot of bits (~128) for the UU characteristics. The Wikipedia page on UUIDs gives more details and has links to relevant standards and specifications.
You seem to be asking if you can use a substring of a UUID. The answer is that if you do this you will probably end up with an identifier that doesn’t have strong enough guarantees of uniqueness.
If you want to generate identifiers for private purposes, they probably don’t need to be universally unique. Your identifiers’ uniqueness requirements (and other characteristics) will depend on the use to which you intend to put them, and without you telling us what they are, it is hard to suggest an appropriate solution. But here are some examples:
It is also necessary to do your sums on the likely rate of identifier generation / use, and consider what happens when your id generator runs out. (Is wrap-around acceptable? Can you reclaim and reissue ids that are no longer used? Does your chosen id representation allow you to expand / extend the id space?)