Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 26 Jul 2011 15:35:04 -0500 Date: Tue, 26 Jul 2011 13:34:56 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: A question about some long java code that has getters/setters References: <1672e2f1-a963-4fcf-b651-41b69432c9d7@p29g2000pre.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 45 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.200.239 X-Trace: sv3-hM47SAMDQ0ACIeGY+Ef4VKg8LQilf9Rfp167g5idIVOsKs4P39yJsLI98MIMPlqZGZkpvRIKbGyfrAG!l4ExIYkGxoj9Z51RUAxcosHdLeL/ocqqnwC7caq3t9GxweRu34VihnBRkYkSLjP4OJV7UJiFrk3m!fkneJ93+GL4paoG4TrexYu+8i7gCk5TvQXcCfocJrvPNn1Y= 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: 3444 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6594 On 7/26/2011 12:15 PM, Stefan Ram wrote: > Gene Wirchenko writes: >>> Since I do not know whether your methods > > (insert »according to their contract«, here) > >>> set the value of an >>> instance variable, I do not know, whether they are »setters« >>> in the sense of my definition. I would need to be able to >>> read their contract (documentation) to learn about this. >> Read my example contract above. It does not mention an instance >> variable, but any reasonable implementation that I am likely to do >> would use one. > > Ok, then - to me - it is not a »setter«. > >> They set something. Whether it is an instance variable or not is >> irrelevant to their use. > > That is even another reason not to make references to instance > variables in the contract of a method. > > A »Setter« to me is a method with a contract like: > > »... sets the private field "alpha" to the argument value.« > > Your method does not set a »field« but a »property« of the object. > Its contract does not allow a party to deduce with > certainity something about the private fields of the object. > Therefore, it does not break encapsulation. > We have two possible definitions of "setter", with corresponding definitions for "getter". 1. A method whose contract specifies setting an instance variable. 2. A method whose contract specifies setting a logical property of the object. To me, it seems wasteful to use an nice, short, simple term for something that should *never* exist, when it could equally well be used for something that is actually useful, so I prefer the second definition. Patricia