I implemented the <examplar> to behave as suggested by Torsten in thread more than a year ago if I got it correctly and it is available in less than 5 min (I loved it). An examplar is JUST a class method returning an instance. For example :), here I just define a class method returning a grid object.
CTGrid class >> 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.
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 pattern from Nautilus point of view.
And now people can use exampleSomething to create/open/display… their lovely examples (that may not return instances) – no stress you have the example you always liked (me too). And we get examplar methods that must return an instance but can behave as example from Nautilus perspective. So a nice win/win:
Better documentation of classes, better code reuse, nice integration and dead simple implementation: One class, 3 methods, no more 🙂
If you want to try
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”
Click on class side of CTGrid and press the triangle and yes you get an inspector on this instance.