0

I've been working as iOS developer for more than 4 years and I've done some other platforms and practised .net. A few days ago I had an argument about who must generate identifier for a newly created entity - client or server?

There is a client-server app, and client sends create request with 'name', 'description' and other stuff. But server-side guy says that I also have to generate GUID and send it over in this entity.

I don't see a big problem in generating GUID but I am just not sure it's right to put that responsibility on a client side.

Any thoughts? Maybe pros and cons?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    We don't give opinions - how would you mark them as correct? They would be subjective, all of which are off topic for this site. You may want to read [ask] – jazb Dec 13 '18 at 04:54
  • 1
    there may be a better forum to post this question too- others here may suggest one or two – jazb Dec 13 '18 at 04:55
  • 1
    in programming everything is measurable. opinion without explanation worths nothing. but if one provides pros and cons with links to resources - it will worth something. and i've read "how to ask" – Sergei Petrachkov Dec 13 '18 at 09:33
  • 1
    i don't make these rules - and a forum without rules is worth nothing – jazb Dec 13 '18 at 12:32

1 Answers1

0

UUIDs being universally unique means that it doesn't matter who generates them, even if there are multiple parties not talking to each other in real time—or at all.

This enables scenarios such as clients creating and using UUIDs offline (perhaps even multiple objects referring to each other) and then uploading them later without any concern about collisions. Whether this is "right" is a matter of opinion and may depend on the specifics of your application, but it is certainly a valid pattern.

StephenS
  • 1,813
  • 13
  • 19