2 ms·
for a function called "getUser" it is.
by _ZeD_ 3y ago
for a function called "getUser" it is.
- withinboredom 3y agoNot exactly. "getUser" not having a user to get is not exceptional unless you only have logged in users. If you have logged-out users, then "getUser" should gracefully handle the case of an unknown, logged-out user (either returning null or some other sentinel value).
- _ZeD_ 3y agoReturning null makes "getUser" a "maybeGetUser" function. Like said in TFA that means that any caller might need to check for nullness
- withinboredom 3y agoYes, no matter what, they have to check if there is an actual user if the application can have anonymous users. There’s no way around that.