Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!newsfeed.x-privat.org!news-out.readnews.com!news-xxxfer.readnews.com!teleglobe.net!newsgate.cuhk.edu.hk!news.netfront.net!not-for-mail From: Wanja Gayk Newsgroups: comp.lang.java.programmer Subject: Re: toward null-safe cookie cutter Comparators Date: Sat, 17 Dec 2011 12:30:11 +0100 Organization: Netfront http://www.netfront.net/ Lines: 43 Message-ID: References: <22790268.15.1321806216236.JavaMail.geo-discussion-forums@prgt40> <9e8b681f-055f-4588-9ef6-3702322b4d3e@c4g2000vbh.googlegroups.com> <2113828.215.1321914010550.JavaMail.geo-discussion-forums@prlm15> NNTP-Posting-Host: 93.130.5.28 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1324121411 40903 93.130.5.28 (17 Dec 2011 11:30:11 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Sat, 17 Dec 2011 11:30:11 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10822 In article , asandstrom3minus1 @eastlink.ca says... > On the subject of catching them, and wrapping them in a "more useful" > exception that holds extra context information, that _sounds_ appealing, > but ask yourself always if the complete stack trace for the NPE doesn't > already tell you what you need to know. Yep, depends. In eleven years of Java programing I have yet to see the golden rule of thumb for these situations. I have seen numerous attempts to wrap exceptions in "business exceptions" that tell you that for example posting an order could not be accomplished, but they hardly added any value because where they were caught or thrown, enough data was present to be able to reconstruct the problem. I have also once tried to create exceptions that you may catch, add information, and rethrow, and those were occasionally useful (for example in a reporting framework, where I added local coordinates and stuff to the exception, so I could tell that layouting did not work, because a cell of height 10 was added to a box of height 5 that was at position x/y relative to its parent that was on position x/y relative to the page, the text was "foo" and of this or that font, etc.). But that try/catch/retrow also cluttered up the source code and made me believe that there was probably something fundamentally wrong with the design of the application. I also thought of some AOP-like proxied interfaces that would enrich a custom exception bubbling through, alas that would not help with private methods or any methodcalls bypassing the proxy because the object calls its own methods, which only leaves code intrumentation as a possible, clean implementation. I have yet to try that, but to be honest: When I come home from work I use to have seen enough code for a day. Kind regards, Wanja -- ..Alesi's problem was that the back of the car was jumping up and down dangerously - and I can assure you from having been teammate to Jean Alesi and knowing what kind of cars that he can pull up with, when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer] --- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---