If I query for an object say for an Animal and the returned object is not null but contains null variables is that wrong? For instance I can call `animal.getDeathDate()`; and since it's not dead yet it returns null. For a Turtle `getFlightSpeed()` would return null since it's unable to fly until it has the Turtle rocket pack added. Etc, etc.
I thought that this was a bad way to do things as it will often cause the need for a lot of null checks while calling the methods of the object to verify that they contain non-null values. Are there any links to information about this that could inform both myself and my coworkers further? You may want the Null Object pattern.
以上就是Is Java object containing null variables an anti-pattern? If so which one?的详细内容，更多请关注web前端其它相关文章！