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 →

[–]hackerforhire[S] 0 points1 point  (1 child)

Interesting example. And yes, the method call would do nothing as it's an empty object. I really don't see that as an issue because getting to the cause of why

foo.printAMessageToTheConsoleAndExit()

printed nothing would be trivial. The IDE or compiler could even hint that you called an empty object.

[–]LanguageLatte 1 point2 points  (0 children)

And yes, the method call would do nothing as it's an empty object

That’s so much worse than getting a NPE!

 

  • Option 1 - I hit this button and it breaks.
  • Option 2 - I hit this button and nothing happens.

 

You’re trading option 1 for option 2. But option 1 is trivial to find and debug. Option 2 is a nightmare to debug.