So today my pr needed approval. One of the lines of code created a unique ID using the uuid4 functionality.
I got a reject saying I didn't handle a case where I would get the same uuid twice.
Well, I guess it would be the problem of the developer working on my code in a couple thousands of years 🤷‍♂️

  • 5
    Well... In theory..... If you generate enough UUIDs.....

    Just add a timestamp to the UUID string.
  • 11
    To be petty, the uuid4 spec does not technically guarantee uniqueness, only statistically uniqueness.

    In almost all cases this is good enough and with a good implementation you will not get duplicates from the same instance.

    But I do know a lot of less secure uuid solutions and its possible the other dev have had problems with such crap.

    But I suggest you verify that instances of the implementation you are using are guaranteed to never provide duplicates in which case you can explain that and avoid bloating the code.
Add Comment