Browsing through the code, I note a method named #left
, which seems perhaps
like an abbreviation. I can ask for senders to see how #left
is used
in code elsewhere.
I notice that most uses of #left
are to indicate a position,
not take an action. How can I fix that?
Because people frequently want to change things for the better, there are a number of handy tools to help do this.
Now I could look at our uses of #left
in Spacewars!, but the Cuis IDE
already knows how to do this!
If I right-click on the Method Pane in the Browser, I get a context menu with selections to help me out. Here I choose Rename.
Now the tools that help us refactor code are quite powerful, so
restraint is called for. I don’t want to change all uses of
#left
in the Cuis-Smalltalk system, just in the Spacewar!
category.
Of course, when making changes one wants to see that the result is what one expects.
As I am not perfect, I tend to save the Cuis-Smalltalk image before I make large changes using powerful tools. If something happens that I did not want, I can then quit the image without saving and restart the saved image which remembers the world before I made the change.
Rename
#right
to#turnRight
.
Looking around some more in the Browser, I notice the method
SpaceShip>>nose
.
Where did I use this? Ah, senders..
Hmmm, perhaps something more specific. How about #noseDirection
?
How does that look?
World menu →
Help
is your friend. TheTerse Guide to Cuise
gives access to a large sample of code usages. TheClass Comment Browser
is an alternate way to find interesting class information. There are also more notes on code maganement and how we use GitHub.
We want to share with you! Please visit packages at the main Cuis-Smalltalk repository at https://github.com/Cuis-Smalltalk, search GitHub for repositories with names starting with Cuis-Smalltalk-, and perhaps take a look at tutorials and information in https://github.com/Cuis-Smalltalk/Learning-Cuis.
There is much more to explore, but this book is an introduction and we have to stop writing text somewhere. This is a good place. We want to get back to writing code! And we look forward to seeing your projects!
Welcome to Cuis-Smalltalk!