Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: DI/wiring Date: Wed, 24 Apr 2013 09:44:15 +0200 Organization: A noiseless patient Spider Lines: 77 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 24 Apr 2013 07:41:12 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="f701c873d1c9639558344ff9364b0d50"; logging-data="10750"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ioYyVK3vTM7L97s+WmzV+" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:WenWTOLrs7FsWD4OsbCRYG7dtCg= Xref: csiph.com comp.lang.java.programmer:23614 On 24/04/2013 06:34, Stefan Ram allegedly wrote: > Daniel Pitts 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.