So much needless UI complexity stems from REST APIs that do these two...
So much needless UI complexity stems from REST APIs that do these two things:
Return null or undefined instead of an empty string.
Return null or undefined instead of an empty array.
Yes, there are exceptions, but generally an empty string or an empty array is preferable.
To clarify, I'm referring to properties on objects in responses.
So, if a user response, prefer:
{
id: 1,
firstName: "",
emails: []
}
over merely returning this to convey a user with no firstName or emails
{
id: 1
}
Another example:
I prefer this:
{
firstName: "",
emails: []
}
over this:
{
firstName: null,
emails: null
}
Do you prefer the latter? If so, why?