Le 18/8/16 à 21:31, stepharo a écrit :
Hi all

I implemented the <examplar> to behave as suggested by torsten and it is available in less than 5 min (I loved it). An example is JUST a class method returning an instance.
examplar is JUST... :)


CTGrid class >> grid22
    <examplar>
    "self grid22"
    | grid1 |
    grid1 := self new: 2.
    grid1 atRow: 1 atColumn: 1 put: 1.
    grid1 atRow: 1 atColumn: 2 put: 3.
    grid1 atRow: 2 atColumn: 1 put: 2.
    grid1 atRow: 2 atColumn: 2 put: 4.
    ^ grid1

You can use this method as any class method in the past. NOTHING new!!
So in particular your test can use it to build a fixture (yes reuse). You can use this method in several test cases (yes reuse).


Now nautilus supports nicely <examplar> methods: you can execute them and get a cool GTInspector open on them. So this is similar to the method exampleSomething from Nautilus point of view. And now people can use example to create/open/... their lovely examples (that may not return instances). And we get examplar methods that must return an instance but can behave as example from Nautilus perspective.

    https://pharo.fogbugz.com/f/cases/18964/support-examplar

If you want to try you can load the CTGrid packages

ScriptLoader new unloadPackageNamed: 'Collections-Grid'.
ScriptLoader new unloadPackageNamed: 'Collections-Grid-Tests'.
"Because there were not good and will be removed from the image"
Gofer it
    url: 'http://smalltalkhub.com/mc/StephaneDucasse/Containers/main';
    configurationOf: 'Grid';
    loadStable

Click on class side of CTGrid and press the triangle and yes you get an inspector on this instance.

Stef





Le 18/8/16 à 14:38, stepharo a écrit :
Hi

In my projects I start to do the following:

I create <examplar> class method that returns an prototypical instance.

I use such methods in my tests as fixture.

Then I would like to have nautilus presenting to me the <examplar> with a little triangle and when I press

on them I get an inspector on them.

This way I get the same behavior than with default <example> methods that open an widget, image....

If we agree on that

- I can take all the <example> and turn them if necessary into examplar.

- extend Nautilus to send an inspect to the result of examplar tagged method.

I think that we can achieve a lot in terms of discovery with such simple changes.

Stef

PS: I reread the old thread and I think that this is a reasonable approach that makes

the pro instances (like me) and the pro examples showing some things (like me) happy.








Reply via email to