Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    Why? How is returning incorrect data any better? Commented Dec 29, 2015 at 23:19
  • 1
    This breaks LSP: see Jimmy Hoffa's answer for an explanation why. Commented Dec 29, 2015 at 23:23
  • 5
    If there are no possible correct return values, it's better to throw an exception than to return an incorrect value. No matter what you do, your program is going to malfunction if it accidentally invokes this property. But if you throw an exception, then it will be obvious why it's malfunctioning. Commented Dec 30, 2015 at 0:39
  • I don't now how the value would be incorrect when your the one implementing the interface! It's your implementation, it can be whatever you want. Commented Dec 30, 2015 at 14:46
  • What if the correct value was unknown upon compile time? Commented Dec 31, 2015 at 7:49