4 ms·
Oooof. Passing in Application IDs will delete applications and passing in site IDs will delete sites. That's a really really bad design. I'm bookmarking this so
by baskethead 4y ago
Oooof. Passing in Application IDs will delete applications and passing in site IDs will delete sites. That's a really really bad design. I'm bookmarking this so that I can use it as a showcase going forward.
Just this week, I changed a spec in one of our proposed endpoints that did exactly that. We passed in ids of various types of objects to perform actions, and I changed the api so that it would be forced to pass in a struct that contained an object type and object id. Explicitness is so much safer in the long run, especially in enterprise apps.
- posnet 4y agoAnd when it comes to user interfaces for deleting, have it repeat back to the person how many, and what is being deleted. And have them type out both the number and they thing they are deleting. https://rachelbythebay.com/w/2020/10/26/num/ https://rachelbythebay.com/w/2020/10/26/num/
- ekimekim 4y agoThis reminds me of how useful it is to make your ids include the type of the thing they're identifying as part of the value. This could be as simple as something like "u<random digits>" for users, "p<random digits>" for projects, etc. Or it could be a full-blown URN scheme like some of the big cloud providers use (though please, whatever you pick, BE CONSISTENT about using that form and only that form. If there's an operation to exact "just the id" from your larger value, and you need to use the full thing in some places and "just the id" in others, then you've missed the point).
- thundergolfer 4y agoYep, this was a situation where humans manually passed IDs between it other, so it would have been great if those IDs were maximally human-readable. Crockford’s 32 encoding with a domain prefix works well enough.