Hi all,
Refactoring is to change a variable name (more important for globals)
and, in an automatic way, the "old" name is changed to the "new"
name in all the scripts belonging to the project.
Doesn't seem too difficult to implement (search-replace?)
Thanks to the creators for the nice scratch system (I'm trying
to engage my 11 years old daughter in programming with it)
JA
Offline
Refactoring is a lot more than just changing variable names.
It refers to major redesign of data structures and program architecture, splitting the problem up differently.
Despite the mis-use of the word "refactoring" I support the idea of providing easy variable renaming. It should also be easy to switch between local and global scope for a variable.
I've often set up a sprite with a local variable, then much later wanted to communicate that value to a new sprite.
The variables would be much easier to work with if there was only one "set <variable> to <value>" and one "change <variable> by <value>" using pull-down lists like for the messages to do the variable names. The variable pane would not get so cluttered then and there would not need to be nearly as much scolling to find variables.
Option-click (or right-click) on variable blocks should allow you to change which variable it is, just like option-click on operation blocks allows changing the operation.
Offline
Changing a variable's scope from global to local still seems risky to me, no matter when you do it. If this is what is being proposed, at the very minimum you should get a message saying what other code segments (or sprites) you are going to affect and allow a yes/no choice before it actually happens.
Last edited by DrJim (2007-06-11 23:55:01)
Offline
Certainly changing the scope of a variable could be risky, so confirmation is appropriate.
But it is much better to be able to change the scope of the variable than to have to manually go through all scripts on all sprites looking for the variable and checking the subtle difference in color!
Offline
Hi all
Nice discussion. Indeed I underestimated the meaning
of refactoring.
In fact, refactoring is much more than changing
variable name. It can be even more deeper than modifying
program architecture: it can be re-programming in a different
language (this is not possible with Scratch, as far as I know).
Will sometime be available a Scratch SDK where one could
make his/her own library of "bricks"? (this is like making its
own subroutines...)
Of course, collective variables such as an "array variable", or better
a "hash variable", would allow for less "verbose" programming.
Finally, some means of creating a "procedure" or "function" or
"subroutine " with the current (1.1) programming environment
would be nice.
Perhaps one day one can "script" the bricks with Python or Lua :-)
JA
PS: by the way, anyone knows if Scratch is based in Smalltalk?
Offline
PS: by the way, anyone knows if Scratch is based in Smalltalk?
~
Yes, it is, at least the Squeak interpreter is.
Offline
The variables would be much easier to work with if there was only one "set <variable> to <value>" and one "change <variable> by <value>" using pull-down lists like for the messages to do the variable names. The variable pane would not get so cluttered then and there would not need to be nearly as much scolling to find variables.
For complex projects yes- but for using it to introduce the whole concept of variables to beginners, the present model works very well.
My class wanted to introduce object picking up in MarbleRacer and we needed a variable to keep a count of the items picked up and the present way seemed to very easy for them to grasp.
But if I had a lot of variables - then your right - the area would become very cluttered :-(
regards
Simon
Offline