DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Mariano Martinez Peck


On Wed, Feb 3, 2010 at 4:34 PM, Chris Muller <[hidden email]> wrote:

4) I have refactored DirectoryEntry to no longer inherit from
ArrayedCollection.  Is this an improvement with any community
interest?



Do you think this is interesting ?   What are the benefits of such change ?

Jannik: do we kill a cycle dependency or something with this change ?

Kind regards,

Mariano

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Marcus Denker-4

On Feb 3, 2010, at 4:43 PM, Mariano Martinez Peck wrote:

>
>
> On Wed, Feb 3, 2010 at 4:34 PM, Chris Muller <[hidden email]> wrote:
>
> 4) I have refactored DirectoryEntry to no longer inherit from
> ArrayedCollection.  Is this an improvement with any community
> interest?
>
> Do you think this is interesting ?   What are the benefits of such change ?
>
> Jannik: do we kill a cycle dependency or something with this change ?
>

You should never inherit from collections. The problem is that with this, you are depending
on the internal working of the collection.

Especially objects that model a domain object (like a Directory related thing) should *never*
inherit from a collection. Only if you need a special *kind* of collection (technically), it might be
interesting to do a subclass of a collection (see MethodDictionary).

If you need a collection, you *use* a collection.  (you put a standard collection as an instance var).

It's very tempting to use inheritance to aquire behavior. But in most cases, it is wrong to use it.

You can see this abuse of inheritance very often in Squeak... e.g. Scanner is the superclass of
Parser, there are subclasses of SystemWindow (!!), things like that. Bad.


        Marcus

--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Chris Muller-3
In reply to this post by Mariano Martinez Peck
Extendability, correctness of semantics, and correctness of
implementation.  Inheritance should adhere to an "is-a" relationship;
because it reflects a specialization of the superclass.  A
DirectoryEntry is definitely not a Collection..

Regards,
  Chris

2010/2/3 Mariano Martinez Peck <[hidden email]>:

>
>
> On Wed, Feb 3, 2010 at 4:34 PM, Chris Muller <[hidden email]> wrote:
>>
>> 4) I have refactored DirectoryEntry to no longer inherit from
>> ArrayedCollection.  Is this an improvement with any community
>> interest?
>>
>
>
> Do you think this is interesting ?   What are the benefits of such change ?
>
> Jannik: do we kill a cycle dependency or something with this change ?
>
> Kind regards,
>
> Mariano
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Mariano Martinez Peck


On Wed, Feb 3, 2010 at 4:55 PM, Chris Muller <[hidden email]> wrote:
Extendability, correctness of semantics, and correctness of
implementation.  Inheritance should adhere to an "is-a" relationship;
because it reflects a specialization of the superclass.  A
DirectoryEntry is definitely not a Collection..


Ahhh I didn't know you were here Chris :)   This is cool.

Thanks for the explanations. My question was exactly because it come to my mind the example of the MethodDictionary or the one I saw yesterday in VMMaker (Interpreter extends from ObjectMemory).

Then yes, we are interested Chris :)  I created the issue:

http://code.google.com/p/pharo/issues/detail?id=1916

If you can submit the changes, would be really cool. The instructions to do that are here:

http://code.google.com/p/pharo/wiki/HowToContribute

As far as it is published, it will be integrated in Pharo 1.1.

Thank you very much.

Mariano
 
Regards,
 Chris

2010/2/3 Mariano Martinez Peck <[hidden email]>:
>
>
> On Wed, Feb 3, 2010 at 4:34 PM, Chris Muller <[hidden email]> wrote:
>>
>> 4) I have refactored DirectoryEntry to no longer inherit from
>> ArrayedCollection.  Is this an improvement with any community
>> interest?
>>
>
>
> Do you think this is interesting ?   What are the benefits of such change ?
>
> Jannik: do we kill a cycle dependency or something with this change ?
>
> Kind regards,
>
> Mariano
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Schwab,Wilhelm K
In reply to this post by Marcus Denker-4
Marcus,

Rats :)  You've stolen my thunder.  Actually, I won't go as far as to say "never," but I agree.  There are places in Squeak that inherit from collections or put methods in Object, and it sure looks as though the programmer didn't know any better.  In fairness, it might have been intended to minimize the chance of runtime errors.  Think about it: by wrongly inheriting from OrderedCollection, one is freed from having to delegate its methods (it's not correct, but can seem wise to a beginner or expedient an experienced programmer with poor tools).  Mess around with the internals of the user interface, and sliding a method up the hierarchy can avoid a meltdown.  These things were all the more true before the days of exception handling.

By all means, we should fix these things as we find them.

Bill



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marcus Denker
Sent: Wednesday, February 03, 2010 10:53 AM
To: [hidden email]
Cc: Laval Jannik
Subject: Re: [Pharo-project] DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions


On Feb 3, 2010, at 4:43 PM, Mariano Martinez Peck wrote:

>
>
> On Wed, Feb 3, 2010 at 4:34 PM, Chris Muller <[hidden email]> wrote:
>
> 4) I have refactored DirectoryEntry to no longer inherit from
> ArrayedCollection.  Is this an improvement with any community
> interest?
>
> Do you think this is interesting ?   What are the benefits of such change ?
>
> Jannik: do we kill a cycle dependency or something with this change ?
>

You should never inherit from collections. The problem is that with this, you are depending on the internal working of the collection.

Especially objects that model a domain object (like a Directory related thing) should *never* inherit from a collection. Only if you need a special *kind* of collection (technically), it might be interesting to do a subclass of a collection (see MethodDictionary).

If you need a collection, you *use* a collection.  (you put a standard collection as an instance var).

It's very tempting to use inheritance to aquire behavior. But in most cases, it is wrong to use it.

You can see this abuse of inheritance very often in Squeak... e.g. Scanner is the superclass of Parser, there are subclasses of SystemWindow (!!), things like that. Bad.


        Marcus

--
Marcus Denker  -- http://www.marcusdenker.de INRIA Lille -- Nord Europe. Team RMoD.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Marcus Denker-4

On Feb 3, 2010, at 5:03 PM, Schwab,Wilhelm K wrote:

> Marcus,
>
> Rats :)  You've stolen my thunder.  Actually, I won't go as far as to say "never," but I agree.  There are places in Squeak that inherit from collections or put methods in Object, and it sure looks as though the programmer didn't know any better.  

And partly, this was because it was done a very long time ago... back than, it was not known how to program with this newly invented object things. Even by the people who invented it! It's
often that others, who than use it, learn how to use it better than the creators.

The same will happen with everything we will invent (if we invent anything, that is :-) ).


        Marcus

--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Igor Stasenko
On 3 February 2010 18:12, Marcus Denker <[hidden email]> wrote:

>
> On Feb 3, 2010, at 5:03 PM, Schwab,Wilhelm K wrote:
>
>> Marcus,
>>
>> Rats :)  You've stolen my thunder.  Actually, I won't go as far as to say "never," but I agree.  There are places in Squeak that inherit from collections or put methods in Object, and it sure looks as though the programmer didn't know any better.
>
> And partly, this was because it was done a very long time ago... back than, it was not known how to program with this newly invented object things. Even by the people who invented it! It's
> often that others, who than use it, learn how to use it better than the creators.
>
> The same will happen with everything we will invent (if we invent anything, that is :-) ).
>
+100

the good thing is, that we're free to change this. While java people
got stuck with sealed stuff forever :)

>
>        Marcus
>
> --
> Marcus Denker  -- http://www.marcusdenker.de
> INRIA Lille -- Nord Europe. Team RMoD.
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions

Schwab,Wilhelm K
In reply to this post by Marcus Denker-4
Very true!





-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marcus Denker
Sent: Wednesday, February 03, 2010 11:13 AM
To: [hidden email]
Subject: Re: [Pharo-project] DirectoryEntry does not inherit from ArrayedCollection [WAS] Re: [squeak-dev] 3.11 questions


On Feb 3, 2010, at 5:03 PM, Schwab,Wilhelm K wrote:

> Marcus,
>
> Rats :)  You've stolen my thunder.  Actually, I won't go as far as to say "never," but I agree.  There are places in Squeak that inherit from collections or put methods in Object, and it sure looks as though the programmer didn't know any better.  

And partly, this was because it was done a very long time ago... back than, it was not known how to program with this newly invented object things. Even by the people who invented it! It's often that others, who than use it, learn how to use it better than the creators.

The same will happen with everything we will invent (if we invent anything, that is :-) ).


        Marcus

--
Marcus Denker  -- http://www.marcusdenker.de INRIA Lille -- Nord Europe. Team RMoD.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project