The classic pattern you see in Smalltalk is
exampleMethod
  "self exampleMethod"
  self
    example;
    code;
    goes;
    here
Then what you do, is navigate to the method, highlight the comment and do it. If you're doing it a lot, it gets tedious to select the comment and then execute it.
So I made a simple little package called RBEasyExampleMethods, put in the repository. It makes it so you can just double click on a method in the browser, and if it looks like an example, it runs it. It looks like an example when it's
- a class side method
- unary (no arguments)
- starts with 'example' OR lives in a category that starts with 'example'
It should work with VisualWorks versions from quite a ways back. Enjoy!
Hello!
ReplyDeleteNice little addition, but could you consider extend it a little bit to also support management-like code? I mean things like:
SomeClass class>>purgeSomething
"Optional explanation what it does."
"self purgeSomething."
...
The rules would be:
* It must be a class side method with no arguments.
* One of its comments has the form "self methodSelector.".
Just my 2cents,
Ladislav Lenart
If you use tests then you can combine the 'Mark I eyeball' test with assertions, either right away or as you work on the task. I think there are many cases where Mark I eyeball and self assert: can cooperate to good effect.
ReplyDeleteOf course, the Mark I eyeball takes time, and a test will normally close the window it opens, perahps too fast. Is this where you see the two maybe conflicting rather than cooperating?
I would rather see this new utility of yours as a modification to SUnit (actually to SUnitToo, I presume, for SUnit to steal later) than an alternative. Is there a case for a button, parallel to the step into button, that, instead of halting at the start of a test, halts at the end, before it begins tearDown? Or an pragma that SUnitToo recognises and handles appropriately?