Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!feeder.news-service.com!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.help Subject: Re: Is it sign of bad Object Oriented programming? Date: Sun, 24 Apr 2011 21:06:06 -0400 Organization: albasani.net Lines: 39 Message-ID: References: <87wriklitz.fsf@merciadriluca-station.MERCIADRILUCA> <2IednYrMyuph4inQnZ2dnUVZ_gWdnZ2d@earthlink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net mW0iuO9Qtb7tDZ6JcLT4s4VgOlEIUTFZF2jwif0ghV34DoihdshZDRYwen+YAnW0U4tE+cyARMc25QYFgV2Vrg== NNTP-Posting-Date: Mon, 25 Apr 2011 01:06:06 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="7vaQkXwggWFSBHFsVWpSgvW3H5YuuWQZ9w1sMFd/VAzicMwwIs7sOCxpj9NckGUgHmPTJ+ZCyhsgBZG/7Zok1oF1kp8T5motD+rDX2nIT9FX9Uo+PKl9AVC2nUmu+oV/"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Cancel-Lock: sha1:ZeqJGWQB0RwtVfNGQspWE4GynOs= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:645 On 04/24/2011 05:42 PM, Patricia Shanahan wrote: > On 4/24/2011 2:26 PM, Lew wrote: >> Patricia Shanahan wrote: > ... >>> Consider an arithmetic type Widget, like BigInteger, with a multiply >>> method that returns the Widget representing the product of this and a >>> Widget argument. >>> >>> Now write Widget's square method: >>> >>> public Widget square() { >>> return multiply(this); >>> } >>> >>> Is that what is being discussed? >> >> Of course, the OP will have to clarify this, but the example given was: >> >> myObj.myMeth(myObj) >> >> This represents a client, not 'this', calling a method that takes the >> reference itself as an argument. Stefan Ram gave a motivating example: >> >> System.out.println( System.out ); >> >> Your example doesn't fit the proffered pattern. >> > > OK. Suppose Widget does not offer a square method, but I need the square > of the Widget referenced by x: > > Widget xSquared = x.multiply(x); Perfect. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg