I know all the advantages of having the descriptions defined in the
instance side. But I find one drawback. Let's suppose I want to implement a tool that works at meta level, and I want a list of the available descriptions of a class in order to build a query where each description will map to a column. Is there any way I can obtain all the instance side descriptors without having to instantiate my object? MyModel has #descriptionA #descriptionB #descriptionC I want something like: MyModel>>#magritteDescriptionOfInstances and get the above mentioned descriptions. I know some descriptions will need specific instance variables in order to work, I would like also to categorize/filter those descriptions that are "class side friendly" (it is, they don't require instance specific behavior). Otherwise I don't see other option than to partition the descriptors to both instance and class side. E.g.: MyModel>>#descriptionA <magritteDescription> ^self class descriptionA MyModel class>>#descriptionA <magritteDescription> ^MAStringDescription new... Any clues? Esteban A. Maringolo _______________________________________________ Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Errata:
Where it says: MyModel>>#magritteDescriptionOfInstances It should say: MyModel class>>#magritteDescriptionOfInstances :) Esteban A. Maringolo 2014-02-27 19:46 GMT-03:00 Esteban A. Maringolo <[hidden email]>: > I know all the advantages of having the descriptions defined in the > instance side. But I find one drawback. > > Let's suppose I want to implement a tool that works at meta level, and > I want a list of the available descriptions of a class in order to > build a query where each description will map to a column. > > Is there any way I can obtain all the instance side descriptors > without having to instantiate my object? > > > MyModel has > #descriptionA > #descriptionB > #descriptionC > > I want something like: MyModel>>#magritteDescriptionOfInstances and > get the above mentioned descriptions. > > I know some descriptions will need specific instance variables in > order to work, I would like also to categorize/filter those > descriptions that are "class side friendly" (it is, they don't require > instance specific behavior). > > Otherwise I don't see other option than to partition the descriptors > to both instance and class side. > > E.g.: > MyModel>>#descriptionA > <magritteDescription> > ^self class descriptionA > > > MyModel class>>#descriptionA > <magritteDescription> > ^MAStringDescription new... > > Any clues? > > > Esteban A. Maringolo Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Hi Esteban,
I “solved” this problem by creating a template object. This template is created once, for all classes and when I need a "description of the class”, I ask the for description of the template. But you are right: most descriptions are static and could be defined on the class side. Allowing them to be defined on both class side and instance side might be a good idea. And this would allow you to ask for the description on the class side as well. And when you ask the description of a concrete object, it get’s enriched with the instance side descriptions. Diego On 27 Feb 2014, at 23:47, Esteban A. Maringolo <[hidden email]> wrote: > Errata: > Where it says: MyModel>>#magritteDescriptionOfInstances > It should say: MyModel class>>#magritteDescriptionOfInstances > > :) > Esteban A. Maringolo > > > 2014-02-27 19:46 GMT-03:00 Esteban A. Maringolo <[hidden email]>: >> I know all the advantages of having the descriptions defined in the >> instance side. But I find one drawback. >> >> Let's suppose I want to implement a tool that works at meta level, and >> I want a list of the available descriptions of a class in order to >> build a query where each description will map to a column. >> >> Is there any way I can obtain all the instance side descriptors >> without having to instantiate my object? >> >> >> MyModel has >> #descriptionA >> #descriptionB >> #descriptionC >> >> I want something like: MyModel>>#magritteDescriptionOfInstances and >> get the above mentioned descriptions. >> >> I know some descriptions will need specific instance variables in >> order to work, I would like also to categorize/filter those >> descriptions that are "class side friendly" (it is, they don't require >> instance specific behavior). >> >> Otherwise I don't see other option than to partition the descriptors >> to both instance and class side. >> >> E.g.: >> MyModel>>#descriptionA >> <magritteDescription> >> ^self class descriptionA >> >> >> MyModel class>>#descriptionA >> <magritteDescription> >> ^MAStringDescription new... >> >> Any clues? >> >> >> Esteban A. Maringolo > _______________________________________________ > Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki _______________________________________________ Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
2014-02-28 4:55 GMT-03:00 Diego Lont <[hidden email]>:
> Hi Esteban, > > I "solved" this problem by creating a template object. This template is created once, for all classes and when I need a "description of the class", I ask the for description of the template. I guess you mean one template instance per class/hierarchy. Do you have a class instance variable for this template instance? > But you are right: most descriptions are static and could be defined on the class side. Allowing them to be defined on both class side and instance side might be a good idea. And this would allow you to ask for the description on the class side as well. And when you ask the description of a concrete object, it get's enriched with the instance side descriptions. Exactly. Dolphin Smalltalk has its own meta descriptions (named "AspectDescriptors" or simply "aspects") that provide specific inspectors and other nice features for its inspectors and toolset. On Object's instance side the #publishedAspects is implemented as: Object>>#publishedAspects "Answer a <LookupTable> of the <Aspect>s published by the receiver." | aspects | aspects := self class publishedAspectsOfInstances. ... ^aspects And in the class side: Object class>>#publishedAspectsOfInstances "Answer a LookupTable of AspectDescriptors that describe the aspects published by an instance of the receiver. Overridden by subclasses to add the aspects published locally." ^(LookupTable new) add: (self newInstanceAspect: #yourself class: Aspect); yourself CompiledCode class>>#publishedAspectsOfInstances "Answer a <LookupTable> of the <Aspect>s published by instances of the receiver." ^(super publishedAspectsOfInstances) add: (Aspect name: #methodClass) beReadOnly; add: (Aspect name: #header) beReadOnly; add: (Aspect integer: #argumentCount) beReadOnly; add: (Aspect multilineString: #getSource) beReadOnly; add: (Aspect name: #byteCodes) beReadOnly; add: (Aspect multilineString: #disassembly) beReadOnly; add: (Aspect name: #literals); yourself You normally work at the instance side, but almost everything is "defined" at the class side. So you can know what is and what is not available. Of course subclasses can "remove" some descriptors from the LookupTable (optimized Dictionary). Although in Magritte that is managed by the MAContainer. Regards! -- Esteban! _______________________________________________ Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Free forum by Nabble | Edit this page |