Fwd: Creating services

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

Fwd: Creating services

stéphane ducasse-2


Begin forwarded message:

> From: Diego Fernandez <[hidden email]>
> Date: 24 janvier 2006 04:24:39 HNEC
> To: stéphane ducasse <[hidden email]>
> Cc: Romain Robbes <[hidden email]>
> Subject: Re: Creating services
>
> Hi Steph, Romain,
> I have loaded the latest Squeak image -6718, hey you are working  
> hard! each time that I check the list there are 2 new versions :).
> In my previous image version (6716) I have loaded 'Services-all'  
> and dependencies (and made a couple of patches to make it work), I  
> know that this in development... and maybe that's why I get so  
> frustrated in dealing with those arrays of symbols :P.
>
> This version is much more polished :)
>
> I cannot found "Create new service" option, so I create the new  
> service evaluating:
> BrowserProvider newServiceFor: 'AutomaticMethodCategorizer-Services'
>
> Then I have created the following methods:
>
> AutomaticMethodCategorizerServicesServiceProvider>>browserMethodCatego
> ryMenuItems {saved preferences}
>     ^ #(#'Items in browserMethodCategoryMenu:' #autocategorize 1 )
>
> AutomaticMethodCategorizerServicesServiceProvider>>autocategorize  
> {services}
>     ^ServiceAction
>         text: 'SERVICE TEST'
>         button: 'SERVICE TEST'
>         description: 'first service' action: [Transcript cr; show:  
> 'It worked :)'].
>
> And do a "Rebuild service registry"
>
> But I can't see the options in the menu. I know that I'm missing  
> something
> Thanks in advance for the help!
>
> An small comment about "saved preferences", if its possible avoid  
> the use of those arrays of symbols, they makes the code more  
> difficult to understand (and refactor). For example if the saved  
> preference is refied you could do something like this:
>
> AutomaticMethodCategorizerServicesServiceProvider>>browserMethodCatego
> ryMenuItems {saved preferences}
>     ^SavedServicePreference named: 'Items in  
> browserMethodCategoryMenu:'
>             service: self autocategorize
>             priority: 1
>
> An then #replayPreferences becomes very simple, for example:
> replayPreferences
>     self savedPreferences applyTo: ServicePreferences
>
> SavedServicePreferences>>applyTo: aServicePreferences
>     preferences do: [:each | each applyTo: aServicePreferences ]
>
> SavedServicePreference>>applyTo: aServicePreferences
>     aServicePreferences setPreference: self name toValue: self value
>
> (the order of the preferences could be responsibility of  
> "SavedServicePreferences"... mmm the name that I choose in the  
> example "Saved.." is not a good one)
>
> Thanks for the patience
> Diego.-
>
>
> On 1/22/06, stéphane ducasse <[hidden email]> wrote: romain
>
> it would be good if you can also describe in class comment how to
> define services programmatically.
>
>
> On 22 janv. 06, at 12:33, Romain Robbes wrote:
>
> >       Hi Diego,
> >
> >       The latest version of services (which is in 3.9) functions  
> a bit
> > differently. I tried to simplify the process as much as I could.
> >
> >       You first have to open a browser and select a method in your
> > package. Then you should pop up the method menu in the
> >       browser, and select the 'Create new service' item. This  
> tells the
> > framework to find the service provider class for your package
> >       (creating it if there isn't any), and then asks you for the
> > identifier of the service, which will also be the name of the method
> >       in which it is implemented. Then it will compile an initial
> > version of the service-producing method, that you can fill with
> >       the description of your item and the actual action it  
> should perform.
> >
> >       To plug it in the browser, you should open the services  
> browser
> > (which is located in the world menu).
> >       There you should find the category of items in which you  
> want to
> > put your service in (browserMethodMenu,
> >       browserClassCategoryMenu, if you want to have it in the  
> browser).
> > You just have to insert the identifier of the service
> >       you created in the space-separated list of names you will  
> find here.
> >
> >       If you want to create several services, you may want to  
> create a
> > submenu of all of them. To do this, create a ServiceCategory
> >       object in your service provider (it is the same procedure  
> than for
> > services, except you need a ServiceCategory object,
> >       not a ServiceAction). Then put this service category in the  
> menu
> > you want to insert your items in, and put you items in
> >       this category instead.
> >
> >
> >       While checking this procedure, I actually found that there  
> is a
> > difference of behavior between version 6706 and version 6713
> >       of squeak preventing this to work:  
> Object>>#perform:orSendTo: has
> > been modified between the two version.
> >
> >       The bottomline is that the following method should be added:
> >
> >       ServiceAction >> perform: selector orSendTo: otherTarget
> >               ^ self perform: selector
> >
> >
> >       Stef, could you put that in the update stream?
> >
> >       Diego, feel free to ask further question if you need to.
> >
> >               Romain
> >
> >
> > Il giorno Jan 21, 2006, alle ore 8:21 PM, stéphane ducasse ha  
> scritto:
> >
> >> Hi diego
> >>
> >> I have been discussing with lukas and we would love to have the
> >> possibility to auto categorise the categories in Browsers and in
> >> particular OmniBrowser. So keep doing your work, I would really
> >> like to include it in the 3.9 full.
> >>
> >>> I'm trying to do tools to simplify testing and check "quality" of
> >>> packages before saving them (thanks Steph and Lucas your
> >>> recommendations on how to do code coverage save me a lot of work).
> >>> I want to do some simple services:
> >>>    - a menu option to run unit tests of a category
> >>>    - a menu option to browse unit test/tested class
> >>>    - a menu option to auto categorize uncategorized method (so
> >>> the AutomaticMethodCategorizer doesn't have to overwrite the
> >>> Browser class)
> >>>
> >>> And I trying to figure out how to make a new "service", but I
> >>> can't figure out what is the correct way to do that.
> >>>
> >>> I must create a subclass of ServiceProvider and implement
> >>> #providedCategories?
> >>
> >> I do not think so. Your services can be defined as extension of
> >> BrowserProvider (may be I'm wrong).
> >> Look at ServiceAction comment (it is a bit obsolete). Romain do
> >> you have a more up to date version.
> >>
> >>
> >>> If this is the case, what is the meaning of the symbol array of
> >>> arrays returned by this method?
> >>>
> >>> small critic/question follows:
> >>> Why #providedCategories returns an array of symbols and not an
> >>> object that reifies the provided categories?
> >>
> >> Stef
> >>
> >
> > --
> >     Romain Robbes
> >     http://www.inf.unisi.ch/~robbes/
> >
> >
> >
>
>