Guiding a rename effort with GTInspector

After a debate on the Pharo mailing list, we ended up choosing to rename all variations of the example* pragmas to gtExample*. Furthermore, as a second step, we also wanted all methods annotated with gtExample* to start with an example prefix because this would not conflict with the behavior from the code browser.

With this occasion, we also decided to go through the list manually to review. This is not a terribly complicated issue except that we are talking about some couple of hundred methods scattered through dozens of classes.

Having to affect multiple pieces of code scattered throughout the system is not an atypical software development problem, and I find it odd at how little support there exists in typical IDEs for something like this. So, how do you keep track of something like this in Pharo?

Here is a variation of a script that we used to keep track of the second step of renaming the method names:

(Object withAllSubclasses flatCollectAsSet: [ :each |
     (Pragma allNamed: #gtExample in: each) ,
     (Pragma allNamed: #gtExample: in: each) ,
     (Pragma allNamed: #gtExampleFrom: in: each) ])
     select: [ :each | each selector beginsWith: 'example' ]

Inspecting the result in the inspector, reveals a small query-scoped browser that allows you to focus only on the task at hand and know precisely when you are finished.


This solution is terribly inexpensive. Essentially, it is a short query combined with some object inspection. The code involved is minimal, too. This is possible exactly because we turned the concept of an IDE on its head, and as a consequence many use cases that are otherwise seen as the exclusive realm of dedicated tools can be handled with compositions of modular and small ones.

Posted by Tudor Girba at 17 May 2015, 4:09 pm with tags story, gt, spike, pharo, moose link