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


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

Re: Primitive return value after exception in method

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail
NNTP-Posting-Date Sun, 08 Sep 2013 03:12:30 -0500
Date Sun, 08 Sep 2013 09:12:23 +0100
From lipska the kat <"nospam at neversurrender dot co dot uk">
Organization Trollbusters 3
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: Primitive return value after exception in method
References <kvumu7$idc$1@speranza.aioe.org> <5222eb58$0$6555$9b4e6d93@newsspool4.arcor-online.net> <52236225$0$296$14726298@news.sunsite.dk> <522373f2$0$6568$9b4e6d93@newsspool3.arcor-online.net> <b8iprdF1jeuU1@mid.individual.net>
In-Reply-To <b8iprdF1jeuU1@mid.individual.net>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
Message-ID <vYednTuW3dzzrLHPnZ2dnUVZ8iCdnZ2d@bt.com> (permalink)
Lines 47
X-Usenet-Provider http://www.giganews.com
X-AuthenticatedUsername NoAuthUser
X-Trace sv3-h5mR6LIkz3OjdofZG3bPrfk+EQb9E69FpF72uTlLKcceQVpwz+sFlwC/8jTqmH9WphbKHH9vYymWSbw!A48JtJe9m1exaMiwKBhmA56p9h3PPUYEPsjUBTnFCaIBeeLL4FzXa/QWnvEWRKa22wWsCGXYVw==
X-Complaints-To abuse@btinternet.com
X-DMCA-Complaints-To abuse@btinternet.com
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 3326
Xref csiph.com comp.lang.java.programmer:25242

Show key headers only | View raw


On 02/09/13 07:34, Robert Klemme wrote:
> On 01.09.2013 19:05, Marcel Müller wrote:
>> On 01.09.13 17.49, Arne Vajhøj wrote:
>>>> Java does not pass any arguments or return values by reference.
>>>> Although
>>>> the passed values might be references itself. But this makes no
>>>> difference here. Fred is never changed by the call to someMethod if
>>>> someMethod throws, regardless of its return type.
>>>
>>> I don't even think that this (for the return value) is particular
>>> Java specific.
>>
>> Well, it is not only Java specific, of course. But there are languages
>> that can return values in case of exceptions. E.g. ABAP comes into my
>> mind.
>
> One can pass values back to the caller in this situation even in Java -
> albeit not via return value.  All you need to do is to pass an object
> reference into the method and modify the state of that object before you
> throw the exception.
>
> Kind regards
>
>      robert

I've just read this thread and frankly I'm surprised that apparently 
experienced developers are apparently suggesting that this sort of thing 
is even attempted. Here's my thinking.

Cohesion is a fundamental aspect of good 'OO' design.
Simply put this means that a class should implement one well defined 
fragment of a system and nothing else.

It seems to follow then that a method of such a class should be equally 
cohesive which means that it should do one small part of the whole.

Given this situation and if we accept that an exception is used to 
indicate to the caller that an exceptional situation has occurred then 
why in the name of sanity would anyone want to rely in any way on a 
value 'returned' from a method that has thrown an exception?

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
GNU/Linux user #560883 - http://www.linuxcounter.net

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


Thread

Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-01 14:30 +0800
  Re: Primitive return value after exception in method Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-09-01 09:23 +0200
    Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-01 15:38 +0800
    Re: Primitive return value after exception in method Arne Vajhøj <arne@vajhoej.dk> - 2013-09-01 11:49 -0400
      Re: Primitive return value after exception in method Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-09-01 19:05 +0200
        Re: Primitive return value after exception in method Robert Klemme <shortcutter@googlemail.com> - 2013-09-02 08:34 +0200
          Re: Primitive return value after exception in method Arne Vajhøj <arne@vajhoej.dk> - 2013-09-02 22:18 -0400
          Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 09:12 +0100
            Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 17:16 +0800
              Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 12:39 +0100
                Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 19:49 +0800
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 12:59 +0100
                Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 20:13 +0800
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 13:15 +0100
                Re: Primitive return value after exception in method Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2013-09-08 20:20 +0800
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 13:27 +0100
            Re: Primitive return value after exception in method Robert Klemme <shortcutter@googlemail.com> - 2013-09-08 12:33 +0200
              Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 12:41 +0100
                Re: Primitive return value after exception in method Robert Klemme <shortcutter@googlemail.com> - 2013-09-08 14:15 +0200
                Re: Primitive return value after exception in method lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-09-08 13:24 +0100
  Re: Primitive return value after exception in method Patricia Shanahan <pats@acm.org> - 2013-09-01 13:57 -0700

csiph-web