in reply to Re^5: A question about method return values and error checking (unnatural)
in thread A question about method return values and error checking

I concur that it's a poor example, but I'm a bit pressed to come up with a good example to demonstrate why it's good practice. Ultimately, I think we agree on what good form should probably be. Maybe if I mull it for a while, I can come up with a better justification.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

  • Comment on Re^6: A question about method return values and error checking (unnatural)

Replies are listed 'Best First'.
Re^7: A question about method return values and error checking (unnatural)
by Anonymous Monk on Nov 06, 2015 at 11:15 UTC

    Decisions in interface design can sometimes have far-reaching consequences. The class of errors where values get injected, omitted or mixed up is typically more disruptive than a case of a missing value.

    To sum it up: where there's a method to fetch a single item, it is probably a good idea to return one item precisely.