Best Practices in Rev development

J. Landman Gay jacque at hyperactivesw.com
Wed Jun 20 18:09:38 EDT 2007


Richard Gaskin wrote:

> So given the freedom of not using explicitVars while fleshing out 
> algorithms, is it really a valuable thing and I'm just lazy?
> 

For the record, I don't like explicitVars because:

1. The main strength of xtalk is that you do not have to declare or type 
variables. Sticking them up there at the top of every handler removes 
one of the main advantages of using Rev in the first place.

2. You can't comment out a long handler using a single set of hyphens 
before the "on" statement. (I often write multiple versions of handlers 
and switch between them.) As soon as you do that, all those "local" 
declarations become script locals and everything goes haywire. You have 
to comment out all of the declarations. If they aren't all at the top, 
you have to comment out the whole handler. That's more work than it 
needs to be if you're going back and forth between a few copies to see 
which one works best.

3. It looks busy and it makes scripts denser and more complicated than 
necessary. I've seen handlers where the declarations can take up almost 
as much room as the code. It's hard to read other people's scripts if 
they use explicitVars because you have to skip over so much junk to get 
to the real business. In large projects it can add significantly to the 
file size on disk.

4. If you change a variable name, you have to go back and change the 
declaration. It's more work to maintain, for something that isn't even 
required by the engine. (I have wondered if people sometimes do it to 
make their code look more like "real" programming to other people.)

5. And finally, what's wrong with being lazy? :) The smart programmer 
finds the easiest way to do things. That's what Rev is all about.

None of these things is outweighed for me by the fact that explicitVars 
might catch a few typos. The engine catches most of those anyway and 
throws an error.

My twelve cents. ;)

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list