in reply to Error handling in chained method calls

I really hope I am not opening a flaming can of worms here, but how about don't chain methods at all? If you don't really need to do it that way and can call each method and check the return values before continuing then don't chain methods-- I think that would be preferred from a maintenance and clarity of code for your average programmer viewpoint. It may cost you more typing, but it is very helpful if you are stepping through the code to be able to put a breakpoint on any of those method calls as well as trace into them.
  • Comment on Re: Error handling in chained method calls

Replies are listed 'Best First'.
Re^2: Error handling in chained method calls
by locked_user sundialsvc4 (Abbot) on Oct 25, 2010 at 13:14 UTC

    I don’t think you run the risk of cooking any night-crawlers here.   These days, the only thing that really matters is that the code you write must be serviceable and clear.   “Cleverness” is not rewarded.   If “chained method calls” seem to be getting in the way of “error handling” (and whether you are attempting them in “just the right way” or not), just scrap that approach and do something that is more obvious and clear ... to you and to those who will follow you.