Skip to main content
9 events
when toggle format what by license comment
May 1, 2020 at 1:15 comment added hfontanez To say that a null check is better and more solid is absolutely false. Null checks forces you to branch off your code which adds more complexity. If you implement the Null Object pattern correctly, you eliminate the need for logic evaluations and simply just use the object. What can be more solid than that?
Dec 16, 2015 at 20:38 comment added shawnhcorey A null object should be usable as though it was a real object. For example, consider IEEE's NaN (not a number). If an equation goes wrong, it is returned. And it can be used for further calculations since any operation on it will return NaN. It simplifies the code since you don't have to check for NaN after every arithmetic operation.
Dec 16, 2015 at 15:35 comment added Telastyn @shawnhcorey - what?
Dec 16, 2015 at 15:27 comment added shawnhcorey Cons: Sane defaults can be used to build new objects. If a non-null object is returned, some of its attributes can be modified when creating another object. If a null object is returned, it can be used to create a new object. In both cases, the same code works. No need for separate code for copy-modify and new. This is part of the philosophy that every line of code is another place for bugs; reducing the lines reduces bugs.
Sep 10, 2012 at 15:27 comment added user470365 What is more catstrophic failure, not being able to send money or sending (and thus no longer having) money without recipient receiving them and not known it before explicit check?
Jun 10, 2012 at 19:42 vote accept CommunityBot moved from User.Id=53019 by developer User.Id=63
Jun 10, 2012 at 19:43
Jun 9, 2012 at 1:01 comment added Apoorv In Pros section: Agree with the first point. The second point is the designers fault because even null can be used where it shouldn't be. Does not say anything bad about the pattern just reflects on the developer who used the pattern incorrectly.
Jun 8, 2012 at 21:52 history edited Telastyn CC BY-SA 3.0
edited body
Jun 8, 2012 at 20:00 history answered Telastyn CC BY-SA 3.0