Friday, October 23, 2009

Scope is either local or global, but not here

Having an animated discussion with a Java programmer is not always the best way to start or finish you day. Java programmers have a valid point about the strong typing of variables that Java requires. This was no contest with Java and UniBasic, because I have spent the better part of the last two weeks changing our Java U2WebLink. I really know what scope is after trying to figure out why Eclipse editor kept pointing out to me that I had my code in the wrong area for the try/catch loop to work.

Had I not been programming in UniBasic so long, I should have known what variable scope is. All of the variables you create in UniBasic are global, so what is the local scope thing anyways. Wikipedia defines local scope as: “…a variable that accessible only from the function or block in which is declared.”

In UniBasic a variable is assigned through a couple of ways. It must be on the left side of any operation such as math or string manipulation. You can introduce variables through Common statements, includes or my perennial favorite Subroutine calls.

So now you ask yourself how a UniBasic programmer keeps track of all of those variables. Surprise I don’t. That’s right I don’t. If the programmer before us was good or bad I don’t sometimes care with how prior programmer handled the variables. If the program is working then the variables are handled correctly. When the program starts malfunctioning then I have to care and must trace the problem.

That is where the fly is in ointment. UniBasic programmers have no tool to show us where all the variables are assigned or re-assigned which Java programmers have built into the Eclipse Java Editor.

U2logic has begun to approach this problem in our XLr8Editor that is based on the Eclipse IDE. Hopefully, in the next few months I will have something positive to show that UniBasic programmers can control their scope as well.

No comments:

Post a Comment