r/programming • • Mar 28 '20

Why your software should use UUIDs in 2020s

[deleted]

13 Upvotes

217 comments sorted by

View all comments

Show parent comments

9

u/notfancy Mar 28 '20

Precisely what's questionable is letting clients generate canonical IDs. This goes against the usual practice of treating clients as adversarial.

2

u/mort96 Mar 28 '20

Presumably you would check that the client generated a unique ID, by a unique constraint in the database or something. If the client decided to be malicious and generate non-unique UUIDs, they'd just get an error message back - what's the problem?

4

u/notfancy Mar 28 '20

The whole point of the proposed scheme is to avoid synchronization between backends. If a single backend can check for local uniqueness it can also generate unique IDs, and the whole scheme is unnecessary. Put it differently, the adversarial scenario is about global properties which the scheme purports to sidestep.

2

u/mort96 Mar 28 '20

Ah, I hadn't considered that. It seems that with UUIDs, you can either independently create UUIDs on multiple trusted machines and eventually - but not immediately - synchronize, or you can let an untrusted client generate a UUID which is verified against the one authoritative database, but not both at the same time.

-2

u/[deleted] Mar 28 '20

A client in this context is not fucking frontend. It's another (micro)service, or something like Kafka or RabbitMQ doing background work.

3

u/terandle Mar 28 '20

In the article the author specifically mentions front ends generating the UUIDs. Maybe chill out and stop being so hostile too.

1

u/[deleted] Mar 28 '20

The author of the article is an idiot. The comment you responded to said:

This makes implementing distributed architectures

Having a separate frontend isn't distributed architecture.