[squeak-dev] isKindOf: in Morphic code...
asqueaker at gmail.com
Tue Jul 5 18:34:52 UTC 2016
What a great discussion! Excellent arguments on all sides.
I agree with Marcel that we should not do wholesale conversion of
isKindOf:'s -- they might be able to go away entirely someday by some
factoring or cleanup.
We should just convert them to standard #is* methods lazily, as
tangible, real-world needs to do so arise.
I do think its wrong to say an is* check represents a "design
failure". Does using #isNil represent a design failure? No. There
is nothing wrong with TSTTCPW. As Marcel said, code lives.
On Tue, Jul 5, 2016 at 12:01 PM, tim Rowledge <tim at rowledge.org> wrote:
>> On 05-07-2016, at 12:45 AM, marcel.taeumel <Marcel.Taeumel at hpi.de> wrote:
>> One more thing: If you really consider to implement the "isClass" check in
>> two unrelated branches of an inheritance tree, you arguably have a design
>> issue. Just use #respondsTo:. For example, TranscriptStream should not
>> implement #isModel but rather implement the Model interface as needed.
>> #respondsTo: will work fine.
> I disagree. Not to checking for protocol but to using #respondsTo: - it’s even slower that isKindOf: ! It doesn’t simply climb the class tree checking the class name, it climbs the class tree checking the name of every method in the methodDictionary!
> The big issue is the design failure implied by the use of this sort of test; we ought to solve as many of those as possible as soon as possible. Swapping an isKindOf: for some isFoo usage is not ideal by any stretch of the imagination but it can at least solve some important performance problems and it at least allows for multiple classes in disjoint hierarchies to respond sensibly. A better choice of names will often help make life clearer - for example #canBeButtonMorphLabel would be much better than #isStringMorph. At least that hints at a protocol test rather class membership.
> We could, of course, implement a real protocol management & testing capability. At one time I thought that Traits might do that but they went moribund before ever really coming to life.
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> An elephant is a mouse with an operating system.
More information about the Squeak-dev