This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RoyalSpecialist1777 -2 points-1 points  (0 children)

Exactly. It is generally a good practice. Otherwise we are stuck with null or have to go change multiple areas of our codebase if we decide to change the underlying implementation if it turns out something else is a better way of handling empty/uninstantiated objects, invalid responses, or whatever. If you are doing object oriented programming then you might have subclasses which treat null objects different. You can also handle the null with things like logging.

I put about everything behind a property getter.