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


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

Re: DI/wiring

From Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: DI/wiring
Date 2013-04-24 09:44 +0200
Organization A noiseless patient Spider
Message-ID <kl82ao$afu$1@dont-email.me> (permalink)
References <DI-wiring-20130418174944@ram.dialup.fu-berlin.de> <MeVbt.370900$Nq4.247520@newsfe21.iad> <conventions-20130424061354@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 24/04/2013 06:34, Stefan Ram allegedly wrote:
> Daniel Pitts <newsgroup.nospam@virtualinfinity.net> writes:
>> Why aren't those simply setters? Must you go against all convention in 
>> every possible way?
> 
>   I just had to remember that remark, when I read a method
>   name of mine that made me smile myself, it was the name
> 
> acceptReportAcceptor
> 
>   . Here is some more context:
> 
> public void acceptReportAcceptor( final ReportAcceptor reportAcceptor )
> { this.reportAcceptor = reportAcceptor; }
> 
>   . But now, honestly, when one sees a hungry man, and gives
>   him some bread and says:
> 
>       »Sir, please accept this bread!«
> 
>   this sound fine to me, while
> 
>       »Sir, please set this bread!«
> 
>   sounds strange. In 
> 
> object.acceptNumber( 2 )
> 
>   I tell the object to accept the number, but what is
> 
> object.setNumber( 2 )
> 
>   supposed to mean? How can the object set the number 2?
>   This makes no sense!
> 
>   But I am not a native English speaker. May be I am missing
>   something here.
> 
>   Imagine I would have called the reportAcceptor
>   »reportSetter«. This would have made no sense to me! This
>   object is supposed to accept a report, not to set a report!
>   The report is already »set« by the caller, the callee is
>   just asked to kindly consider accepting it!
> 
>> Why aren't those simply setters?
> 
>   Actually I do not know the definition of »setter« that you
>   take as basis for your question. When do you call something
>   a setter?
> 

You give that bread to the hungry man to be his property; yet bread is
not a property of a hungry man (except perhaps a boolean one). Or again
without the wordplay: you give that bread to the hungry man to be his
possession; yet bread is not a quality of a hungry man. The closest
equivalent in engineering terms is that you give it to him for
/processing/, to do something with, to consume. If he's hungry enough,
he'll eat it; if he's gluten sensitive, he won't; if he's a Goldman
Sachs banker, he'll short the bread and long the Yen. In either case,
"bread" is not a quality of any man, hungry or not. Hungriness, however,
is. And while on an object whose purpose would be to re-form the
Austro-Hungarian empire, you might define a method call "acceptHungary",
you wouldn't call a method "acceptHungry" if you wanted to determine
whether not that object was hungry or not, would you? Or, to put it
differently, imagine you had your own Goldman-Sachs banker to play with,
and could resist the urge to arrange his timely and painful demise (it's
a stretch, but bear with me). There might be numerous qualities of his
you might want to alter: his hairdo, his clothing, his level of naked
short selling... In each case, you'd use a setter: "setHairdo",
"setClothing", "setLevelOfNakedShortSelling". It would be totally
pointless to say, for instance, "acceptLevelOfShortSelling". Why, he'd
probably double down on whatever you specify on his own anyway!

HTH,

-- 
DF.

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


Thread

Re: DI/wiring Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-04-18 09:32 -0700
  Re: DI/wiring Lew <lewbloch@gmail.com> - 2013-04-23 23:32 -0700
  Re: DI/wiring Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-04-24 09:44 +0200
  Re: DI/wiring Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-24 09:19 -0300
  Re: DI/wiring Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-04-24 08:40 -0700
    Re: DI/wiring Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-24 13:05 -0300
    Re: DI/wiring Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-04-24 21:14 +0200
  Re: DI/wiring Joerg Meier <joergmmeier@arcor.de> - 2013-04-24 20:13 +0200
    Re: DI/wiring markspace <markspace@nospam.nospam> - 2013-04-24 14:22 -0700

csiph-web