On 14 May 2013, at 17:35, Benjamin <benjamin.vanryseghem.ph...@gmail.com> wrote:
> Something like > > self performIfExists: #blah > > would reduce the noise a lot :) > Then in this methods, we do what we want ^^ IMHO, lots of #respondsTo: or #isKindOf: are a sign of bad code, bad design. But in a number of key places a #performIfExists: can be very helpful and even necessary. Sven > Ben > > On May 14, 2013, at 5:32 PM, Frank Shearar <frank.shea...@gmail.com> wrote: > >> On 14 May 2013 16:21, Stéphane Ducasse <stephane.duca...@inria.fr> wrote: >>> Hi >>> >>> I'm in favor killing all the respondsTo: >>> >>> acceptTextMorphs >>> "Accept any text morphs except for those that have no edits." >>> >>> self allMorphs do: [:p | >>> ((p respondsTo: #accept) and: [ >>> (p respondsTo: #hasUnacceptedEdits) and: [ >>> p hasUnacceptedEdits]]) ifTrue: [p accept]] >> >> They're a step up from #isKindOf:. It looks like you need is something >> that says "does this object respond to a particular set of messages >> (i.e., a Protocol)?". (No, Nicolas, I don't mean a message category! >> :) ) >> >> But in this particular case the solution looks like making a >> #insertADecentNameHere that particular classes of things can implement >> as "^ self hasUnacceptedEdits ifTrue: [self accept]" >> >> frank >> >