Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #641
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Is it sign of bad Object Oriented programming? |
| Date | 2011-04-24 15:21 -0400 |
| Organization | albasani.net |
| Message-ID | <ip1t77$qlh$1@news.albasani.net> (permalink) |
| References | <87wriklitz.fsf@merciadriluca-station.MERCIADRILUCA> <ip1hhr$ef2$1@dont-email.me> |
Eric Sosman wrote:
> Merciadri Luca wrote:
>> Let us consider a class Class and an object myObj of type Class. Let
>> there be a method myMeth defined in the Class class.
>>
>> Are there some cases where typing e.g.
>> ==
>> myObj.myMeth(myObj)
>> ==
>> is not considered as `bad style?' That is, are there, more generally,
>> some situations where passing an instanciated object to a method of
>> this object is a good way of achieving something?
> boolean arrayHasEqualThing(Thing[] array, Thing thing) {
> for (Thing t : array) {
> if (t.equals(thing)) // Look here!
> return true;
> }
> return false;
> }
This differs from the problem statement, which has the argument reference the
same instance as that through which the (instance) method is called. The
method that you show here is a candidate for 'static' scope as it does not
depend on the state of 'this'. In particular, there is no guarantee in this
proposal that 't' or 'thing' point to the 'this' instance, nor to the same
instance as each other.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
Is it sign of bad Object Oriented programming? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-24 00:10 +0200
Re: Is it sign of bad Object Oriented programming? Lew <noone@lewscanon.com> - 2011-04-23 18:31 -0400
Re: Is it sign of bad Object Oriented programming? Lew <noone@lewscanon.com> - 2011-04-23 18:32 -0400
Re: Is it sign of bad Object Oriented programming? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-24 00:57 +0200
Re: Is it sign of bad Object Oriented programming? Roedy Green <see_website@mindprod.com.invalid> - 2011-04-24 06:55 -0700
Re: Is it sign of bad Object Oriented programming? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-24 12:01 -0400
Re: Is it sign of bad Object Oriented programming? Lew <noone@lewscanon.com> - 2011-04-24 15:21 -0400
Re: Is it sign of bad Object Oriented programming? Patricia Shanahan <pats@acm.org> - 2011-04-24 12:54 -0700
Re: Is it sign of bad Object Oriented programming? Lew <noone@lewscanon.com> - 2011-04-24 17:26 -0400
Re: Is it sign of bad Object Oriented programming? Patricia Shanahan <pats@acm.org> - 2011-04-24 14:42 -0700
Re: Is it sign of bad Object Oriented programming? Lew <noone@lewscanon.com> - 2011-04-24 21:06 -0400
csiph-web