[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Discussion on global variables in IDL



I think Martin went more into the programming details here, giving
useful development ideas. What I would like to address, is the *purpose*
of IDL sessions.
You can either use IDL for ad-hoc testing of ideas (and this is what it
looks to me Dmitry is doing, from the "write two lines, debug, and write
next two"). Or you can write an *application* that will process the data
you need. In the latter case, if it turns out the user needs "global"
variables, it means that the application is not encompassing enough
within the IDL session. It means that an *application* is trying to
access ad-hoc data. If you write a program in IDL, think about it as if
it is to become a standalone program: how do you pass "global" data to
Photoshop, for example? And what is "global" data in this case?
If you do need a widget program to aid in the ad-hoc work, pass in the
"global" data via parameters or keywords.
Of course there are special cases, for instance data aquisition systems.
But if you are at that level and still remember about common blocks, you
are risking a dishonorable discharge from the EPA :-)
Common blocks are useful - there is little doubt about it. But I can see
very, very few instances when they are the only way. And the entire idea
of "global" variables seems to me to be resulting from the evolutionary
approach to programming - start with command line data analyses, get
tired of copy-paste. write code, expand it and still need to access the
data the way you started it.
Cheers,
Pavel
P.S. Of course, all the above is pure speculation. But I learned the
hard way that, no matter how tempting it is to just sit and write IDL
code as you think, it pays to design your data organization first, and
design the ways it is to be processed. Even more so when trying to write
useful object programs.