Hi Damien,
> reading VisualWorks code, I've seen an interesting pattern for the > isAbstract method that make subclasses concrete by default: > > isAbstract > "Override to true if a subclass is Abstract" > > ^self name = #TestResource this is SUnit, it is exactly the same in Squeak. > It can clean a bit things on all the Pier and Magritte hierarchies > in my opinion. What do you think about this ? (yes, I'm always > interested in your design opinions) There are two major problems with this approach: * It introduces a direct class reference, renaming the class TestResource breaks the implementation. * It only works for flat hierarchies where you have an abstract superclass and all the direct or indirect subclasses are concrete, unless you re-implement #isAbstract. In Pier and Magritte there are mostly many abstract classes inheriting from each other. The advantage of this approach is: * You only need to implement #isAbstract if you introduce a new abstract class, otherwise the answer is already correct. Maybe other people have other advantages/disadvantages? Or other ideas how to solve this particular problem. Not to mention that #isAbstract could be also calculated dynamically ... Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
> How would you calculate dynamically #isAbstract for a PRCommand for
> example ? If I remember correctly, for the project I've done using > Magritte/Pier/MySQL, I implemented #doExecute for an abstract command. Something along the lines ... Behavior>>isAbstract ^ self allSelectors anySatisfy: [ :each | (self lookupSelector: each) hasLiteral: #subclassResponsibility ] ] Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
In reply to this post by Lukas Renggli-2
>>> How would you calculate dynamically #isAbstract for a PRCommand
>>> for example ? If I remember correctly, for the project I've done >>> using Magritte/Pier/MySQL, I implemented #doExecute for an >>> abstract command. >> Something along the lines ... >> Behavior>>isAbstract >> ^ self allSelectors anySatisfy: [ :each | >> (self lookupSelector: each) >> hasLiteral: #subclassResponsibility ] ] > > > I think this works for real abstract classes. But it doesn't work > when the developer expect subclasses to send super and not override > particular methods. True. Object is an example, but can't think of any other core class that does this. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
Am 11.07.2006 um 21:09 schrieb Lukas Renggli:
>>>> How would you calculate dynamically #isAbstract for a PRCommand >>>> for example ? If I remember correctly, for the project I've done >>>> using Magritte/Pier/MySQL, I implemented #doExecute for an >>>> abstract command. >>> Something along the lines ... >>> Behavior>>isAbstract >>> ^ self allSelectors anySatisfy: [ :each | >>> (self lookupSelector: each) >>> hasLiteral: #subclassResponsibility ] ] >> >> >> I think this works for real abstract classes. But it doesn't work >> when the developer expect subclasses to send super and not override >> particular methods. > > True. Object is an example, but can't think of any other core class > that does this. I wouldn't count Object as an example because it's not an abstract class. - Bert - _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
> I wouldn't count Object as an example because it's not an abstract
> class. Why do you think Object is not an abstract class? -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
Look for methods sending 'Object new' in your image. I found a few dozens
in my VASt image. Instances of Object are often used as (temporary) unique objects. Cheers, Adriaan. >> I wouldn't count Object as an example because it's not an abstract >> class. > > Why do you think Object is not an abstract class? > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki > -- http://vdg38bis.xs4all.nl _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
2006/7/12, Adriaan van Os <[hidden email]>:
> Look for methods sending 'Object new' in your image. I found a few dozens > in my VASt image. Look at all the self sends in Object that are not implemented in Object. ;) (This may not be the case in VASt) Philippe _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
> Look for methods sending 'Object new' in your image. I found a few
> dozens in my VASt image. Yes, I know, but this is not something Object is designed for. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
On Jul 12, 2006, at 6:34 AM, Lukas Renggli wrote: >> Look for methods sending 'Object new' in your image. I found a few >> dozens in my VASt image. > > Yes, I know, but this is not something Object is designed for. Well, this is Smalltalk. There is no hard and fast definition of "Abstract class." What if you create an instance of a class that has methods that send #subclassResponsibility, but never call those methods? If you have a class with a complete implementation of some concept, but only happen to create instances of its subclasses, is it abstract or concrete? How about a class that sends #subclassResponsibility but answers #isAbstract with true? How many angels can dance on the head of a pin? For purposes of SUnit, the meaning of "abstract" is simple. A TestCase subclass that answers #isAbstract with true will not be included in automatically built TestSuites. It's that simple. With that purpose in mind, the existing implementation is fine: It works nicely for the common case - a single abstract class with several concrete subclasses It's simple, so that in the uncommon case of several levels of abstract classes, the redundant implementations are easy to write and easy to understand If an abstract class is renamed, #isAbstract shows up as a reference, and can be updated easily Colin _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
I get an error when loading the latest Pier-Seaside package lr.74
UndefinedObject does not Understand #isSeparator. Keith p.s. I am using 3.8-6665 ___________________________________________________________ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
> I get an error when loading the latest Pier-Seaside package lr.74
> UndefinedObject does not Understand #isSeparator. What is the stack-trace? Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Smallwiki mailing list [hidden email] http://impara.de/mailman/listinfo/smallwiki |
Free forum by Nabble | Edit this page |