Hacker News new | past | comments | ask | show | jobs | submit login

Checking for null on every method invocation? I usually call methods for a reason and if my object is null, I have an error. If I have a situation where an object may be null, there will be specific handling for that case.

The other "patterns" are fishy too. How has this gotten so many points?




Checking for null on every method call certainly sounds nuts to me. Furthermore I would argue that doing so decreases consistence in your program. For example, in Objective-C I can count on nil being returned every time I call a method on a nil object. The opposite is true for other languages. The point is, it renders me able to make certain assumptions about how my code will behave, and thereby reduces the amount of code and tests I have to write.

Now if the language you're using behaves opposite of your wish, you're either using the wrong language or doing things the wrong way.


The author's response to a comment destroys the article's credibility by saying the difference between '==' and '===' is purely stylistic. I think somewhere down the line the author started to run before he could walk and that'll definitely come back to haunt him.


I have never claimed the choice between '==' and '===' is stylistic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: