Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10664

Re: toward null-safe cookie cutter Comparators

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: toward null-safe cookie cutter Comparators
References (9 earlier) <2113828.215.1321914010550.JavaMail.geo-discussion-forums@prlm15> <MPG.294d5cdf98fe754a9896d3@202.177.16.121> <m2sjkspbde.fsf@wantspam.net> <qYNEq.13639$_H.5073@newsfe16.iad> <m262hnfqca.fsf@email.com>
Message-ID <IMlFq.15279$U16.68@newsfe15.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-12-12 07:42 -0400

Show all headers | View raw


On 11-12-11 04:46 AM, ilAn wrote:
> Arved Sandstrom <asandstrom3minus1@eastlink.ca> writes:
> 
>> On 11-12-10 01:47 PM, ilAn wrote:
>>> Wanja Gayk <brixomatic@yahoo.com> writes:
> 
>>
>> Did you (ilAn) read the very last bit in Jim Shore's PDF, where he talks
>> about global exception handlers in production? *This* is what Wanja was
>> getting at, and I myself espouse this approach also.
> 
> Yes I did. I was not sure that was what Wanja was getting at...
> 
> Is it Wanja?
> 
> It seemed Wanja was saying that the codebase he/she is working with
> nulls are commonly passed around if data was not "correct"; potentially
> causing a null pointer exception somewhere else in the codebase... and
> then just throwing that null pointer; and not catching it as early as
> possible and replacing it with an Exception that contains some state
> information and context for that Null Pointer.
> 
> Wanja, did I misunderstand you?

As I read it and understood it, the scenario is the very common one of
null value handling, where "null" is a problem value - you cannot
proceed any further on the happy path with it.

Did he flat out advocate re-throwing NPEs? I didn't see that, I saw him
talking about letting them bubble up without catching them at all. The
only thing that would catch them would be a global exception handler
that is looking for NPEs.

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. If not, the tactic of wrapping
with extra information may be appropraite, but then so might be always
logging the potentially offending method call with parameter
information. One size doesn't fit all.

>> "Fail fast" means not attempting to handle a problem that cannot be
>> handled at runtime. No catch-all exception handlers, no dubious
>> defaults. Be aware of what cannot be handled (configuration file not
>> found, unexpected NPE, etc) and pass it up immediately to a global
>> exception handler and either (1) stop the program (development, maybe
>> test) or (2) stop the individual task and provide help as to what to do
>> next (production).
>>
>> Handling locally - what you've misidentified as "fail fast" - is
>> appropriate only for expected exceptions that can actually be sensibly
>> handled.
> 
> You are assuming I have misidentified something. 

Well, not assuming, I'm flat out saying it based on your own words. In
your previous response you conflated "fail fast" with "as early as
possible". To be more precise, you apparently think (or thought) that
"fail fast" _identically_ means catching locally.

Catching locally could be one way in which you fail fast. But then so is
a global exception handler - which you'll have seen from Jim Shore's PDF
then requires that you do not _handle_ locally, although you could
certainly catch locally, enhance, and re-throw a wrapper to the global
exception handler.

You could certainly catch locally *and* handle locally, which depending
on what you do in the handling may or may not be "fail fast". If you
attempt to proceed when you oughtn't, that's not fail fast.

> But I guess by assuming that, you get a suitable springboard to
> reiterate what was in the article. A useful rhetorical trick I suppose.

Rhetorical trick? We may have read the same PDF but we sure didn't
understand it the same way. So obviously I felt the need to mention
parts of it.

>> I've helped revamp a number of enterprise web applications to this
>> global exception handler model, and now rather than users seeing nasty
>> exception traces or virtually non-reproducible problem behaviour they
>> get a short but sweet error page that supplies screenshot info they can
>> paste into the defect tracking system before they call ops support. The
>> details are also logged.
> 
> I never suggested otherwise.
> 
> In fact why would anyone suggest otherwise? 
> 
> You don't need to turn me into a scarecrow to make your arguments and
> describe how you revamp enterprise web applications so well. 
> 
> I believe you are excellent developer; you don't need to insult me to
> prove that.

No insults intended. Not even in this reply. This is a purely
professional discussion. It's a good and interesting discussion - this
entire topic is one with a great variety of useful perspectives and
opinions and approaches, and it's one of the most important topics in
writing quality software.

AHS

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

toward null-safe cookie cutter Comparators Roedy Green <see_website@mindprod.com.invalid> - 2011-11-13 09:17 -0800
  Re: toward null-safe cookie cutter Comparators Tom Anderson <twic@urchin.earth.li> - 2011-11-13 17:59 +0000
    Re: toward null-safe cookie cutter Comparators Roedy Green <see_website@mindprod.com.invalid> - 2011-11-14 10:28 -0800
      Re: toward null-safe cookie cutter Comparators Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-14 10:55 -0800
        Re: toward null-safe cookie cutter Comparators Roedy Green <see_website@mindprod.com.invalid> - 2011-11-15 09:04 -0800
        Re: toward null-safe cookie cutter Comparators kensi <kensi_kensington@zoonoses.de> - 2011-11-16 12:50 -0500
          Re: toward null-safe cookie cutter Comparators Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-16 13:47 -0800
            Re: toward null-safe cookie cutter Comparators Gene Wirchenko <genew@ocis.net> - 2011-11-16 16:09 -0800
              Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-16 17:02 -0800
                Re: toward null-safe cookie cutter Comparators Gene Wirchenko <genew@ocis.net> - 2011-11-16 17:31 -0800
              Re: toward null-safe cookie cutter Comparators Martin Gregorie <martin@address-in-sig.invalid> - 2011-11-17 22:51 +0000
            Re: toward null-safe cookie cutter Comparators Paul Cager <paul.cager@googlemail.com> - 2011-11-17 02:43 -0800
              Re: toward null-safe cookie cutter Comparators Tim Slattery <Slattery_T@bls.gov> - 2011-11-17 08:57 -0500
              Re: toward null-safe cookie cutter Comparators Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-18 16:05 -0800
            Re: toward null-safe cookie cutter Comparators kensi <kensi_kensington@zoonoses.de> - 2011-11-17 21:21 -0500
            Re: toward null-safe cookie cutter Comparators Wanja Gayk <brixomatic@yahoo.com> - 2011-11-20 13:29 +0100
              Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-20 08:23 -0800
                Re: toward null-safe cookie cutter Comparators Brixomatic <wanja.gayk@googlemail.com> - 2011-11-21 04:39 -0800
                Re: toward null-safe cookie cutter Comparators Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-21 11:25 -0800
                Re: toward null-safe cookie cutter Comparators Arne Vajhøj <arne@vajhoej.dk> - 2011-11-25 21:44 -0500
                Re: toward null-safe cookie cutter Comparators Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-11-26 15:34 -0800
                Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-21 14:20 -0800
                Re: toward null-safe cookie cutter Comparators Gene Wirchenko <genew@ocis.net> - 2011-11-21 19:22 -0800
                Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-21 22:45 -0800
                Re: toward null-safe cookie cutter Comparators Wanja Gayk <brixomatic@yahoo.com> - 2011-12-10 12:15 +0100
                Re: toward null-safe cookie cutter Comparators ilAn <idonot@wantspam.net> - 2011-12-10 19:47 +0200
                Re: toward null-safe cookie cutter Comparators Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-12-10 14:57 -0400
                Re: toward null-safe cookie cutter Comparators ilAn <nosuch@email.com> - 2011-12-11 10:46 +0200
                Re: toward null-safe cookie cutter Comparators Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-12-12 07:42 -0400
                Re: toward null-safe cookie cutter Comparators ilAn <nosuch@email.com> - 2011-12-12 16:06 +0200
                Re: toward null-safe cookie cutter Comparators "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-12-13 02:01 +1100
                Re: toward null-safe cookie cutter Comparators Wanja Gayk <brixomatic@yahoo.com> - 2011-12-17 12:30 +0100
                Re: toward null-safe cookie cutter Comparators Wanja Gayk <brixomatic@yahoo.com> - 2011-12-17 12:30 +0100
            Re: toward null-safe cookie cutter Comparators Roedy Green <see_website@mindprod.com.invalid> - 2011-11-22 19:47 -0800
          Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-16 14:02 -0800
            Re: toward null-safe cookie cutter Comparators Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-17 08:42 +0000
          Re: toward null-safe cookie cutter Comparators Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-11-17 15:09 +0000
            Re: toward null-safe cookie cutter Comparators kensi <kensi_kensington@zoonoses.de> - 2011-11-17 21:22 -0500
          Re: toward null-safe cookie cutter Comparators spk <jhic@speak.invalid> - 2011-11-17 13:40 -0400
            Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-17 09:56 -0800
              Re: toward null-safe cookie cutter Comparators spk <jhic@speak.invalid> - 2011-11-17 14:00 -0400
                Re: toward null-safe cookie cutter Comparators Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-17 19:23 +0000
                Re: toward null-safe cookie cutter Comparators spk <jhic@speak.invalid> - 2011-11-17 16:35 -0400
                Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-17 13:50 -0800
                Re: toward null-safe cookie cutter Comparators spk <jhic@speak.invalid> - 2011-11-17 18:48 -0400
                Re: toward null-safe cookie cutter Comparators thoolen <tholen01@gmail.com> - 2011-11-17 18:33 -0800
                Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-17 13:48 -0800
                Re: toward null-safe cookie cutter Comparators "Joe Attardi" <jattard1@gmail.com> - 2011-11-18 12:20 +0100
                Re: toward null-safe cookie cutter Comparators thoolen <th00len@th0lenbot.thorium> - 2011-11-18 15:21 -0500
            Re: toward null-safe cookie cutter Comparators thoolen <tholen01@gmail.com> - 2011-11-17 18:31 -0800
    Re: toward null-safe cookie cutter Comparators Wanja Gayk <brixomatic@yahoo.com> - 2011-11-20 13:14 +0100
      Re: toward null-safe cookie cutter Comparators Lew <lewbloch@gmail.com> - 2011-11-20 08:29 -0800
        Re: toward null-safe cookie cutter Comparators Brixomatic <wanja.gayk@googlemail.com> - 2011-11-21 04:03 -0800

csiph-web