January 12, 2017

Give Your Objects Unique Names

Get in the habit of naming projects, objects, scripts and variables. Values are frequently selected from drop down lists and it's easy to confuse which script2 or var3 you need if you are working with multiple objects. This will lead to avoidable scripting errors.

If you use a Squeak reserved word to name an object usually Etoys will append a number to the name. A variable named "count" will be changed to "count1". Today I learned that script names prefaced with the word get will be changed in the viewer but not in the Script Editor or the All Scripts tool. For example a script named "getEllipseColor" gets renamed "ellipseColor" in the viewer. This confused me rather badly when reviewing a project today. If you see this kind of discrepancy in your script names it likely means you have used a reserved word. To resolve it, remove all references to the script inside other scripts and rename it. You can now add the tiles you removed back to your scripts.

Descriptive names make projects easier to follow for other users or even yourself if you haven't opened one in a while. Flaps are useful containers for text documentation. Most objects have an option to create balloon help in their halo menu options.

You might notice throughout the pages of this blog that I don't seem to always follow my own advice. I'm sure I have reasons.



Last Updated  .