Timeline for What should a rest api return for an empty guid?
Current License: CC BY-SA 3.0
22 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 14, 2017 at 14:17 | vote | accept | Sturla | ||
Nov 14, 2017 at 14:16 | vote | accept | Sturla | ||
Nov 14, 2017 at 14:17 | |||||
Jul 4, 2017 at 12:20 | answer | added | Daniel T. | timeline score: 1 | |
Jun 25, 2017 at 12:42 | history | tweeted | twitter.com/StackSoftEng/status/878956584172490752 | ||
Jun 24, 2017 at 13:11 | comment | added | RubberDuck | There's an important difference between an "empty" constant and null: one will cause NREs and the other won't. Both need to be checked and handled, so pick your poison. Want to fail fast, or fail silently? | |
Jun 24, 2017 at 12:46 | comment | added | Andy | I suspect .Net only has Guid.Empty because in the 1.0 release there were no generics and no Nullable<T>, so Empty became a stand in to mean null, since Guid is a value type, but its not actually a valid guid value. In the code base I work in today, for some reason there are Guid?s everywhere, and both Empty and null semantically mean the same thing. Its pretty annoying, and I've been making the Guid's non-nullable so I don't have to keep checking both cases, but that's only because there's now way to get rid of Guid.Empty. | |
Jun 24, 2017 at 12:20 | comment | added | Laiv | The server side can not look after of all the singularities of the client-side. There could be many and different consumers. If iOS need to code a parser from scratch, then do It. Anyaways, I agree with Ewan, don't use "magic numbers". | |
Jun 24, 2017 at 12:03 | answer | added | gnasher729 | timeline score: 0 | |
Jun 23, 2017 at 12:46 | comment | added | Machado | @Sturla, yes, it's a specific .Net convention, as the Empty Guid constant it's built-in on the Guid type (just like string.Empty constant is exposed on the string object). But your point is not wrong, since the Guid is just the Microsoft implementation of the UUID standard. Going with null/non-existing Guid is just as valid as going with the empty one, depending on the meaning of it in the domain problem. | |
Jun 23, 2017 at 10:45 | comment | added | Esben Skov Pedersen | I don't know where you would expect me to find such a citation. As you experienced, empty guids caused you problems. When there is an alternative without any real drawbacks we simply use that. | |
Jun 23, 2017 at 10:40 | comment | added | Sturla | @EsbenSkovPedersen can you point me to information saying this is best practice but not just your best practice. I´m leaning into it being the right thing to do but I need more to accept it as the truth/correct answer. | |
Jun 23, 2017 at 10:33 | comment | added | Esben Skov Pedersen | @Sturla as I write in my answer - best practice is to not expose empty guids but instead expose null or nothing. | |
Jun 23, 2017 at 10:31 | comment | added | Sturla | @EsbenSkovPedersen its not causing me any special problems. I control both ends of the system, so I can really do what I like to make it work. I´m just looking for "best practice" information about this issue. | |
Jun 23, 2017 at 10:29 | comment | added | Sturla | @Machado well is it a .net convention? "The "nil" UUID, a special case, is the UUID" en.wikipedia.org/wiki/Universally_unique_identifier#Standards | |
Jun 23, 2017 at 7:58 | answer | added | Ewan | timeline score: 5 | |
Jun 23, 2017 at 7:50 | comment | added | Ewan | you should always use empty guids where possible to avoid using up the world supply of guids too quickly | |
Jun 22, 2017 at 19:11 | comment | added | Esben Skov Pedersen | Why would you choose the first one when it is causing you problems? | |
Jun 22, 2017 at 18:00 | answer | added | Esben Skov Pedersen | timeline score: -2 | |
Jun 22, 2017 at 17:21 | comment | added | Machado | Empty Guid is different than non-existing Guid. By all means the convention of empty on .Net is 00....00, but you may not want to leak this convention to a public API that's used by other platforms. Instead of trying to define what's empty and what's not, you have to define the meaning of having and not having a Guid, use a convention that would be easy for all platforms (web, IOS, Android, etc...) and keep it as the protocol. | |
Jun 22, 2017 at 17:20 | comment | added | Kevin Fee | Firstly, what's he do if it's not an empty GUID? Also, why does he need a parse method for empty but not a non-empty GUID? Can't he just do an equality check against the string "00000000-0000-0000-0000-000000000000"? | |
Jun 22, 2017 at 17:16 | review | First posts | |||
Jul 16, 2017 at 10:06 | |||||
Jun 22, 2017 at 17:15 | history | asked | Sturla | CC BY-SA 3.0 |