Re: can i place a job advert [message #28126] |
Mon, 26 November 2001 09:13  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
William Thompson wrote:
>
> Paul van Delst <paul.vandelst@noaa.gov> writes:
>
>> "Pavel A. Romashkin" wrote:
>>>
>>> Oh, people have done much worse things here and got away with it. Like
>>> admitting to using common blocks. Go ahead...
>
>> Wot's wrong with common blocks? They seem like quite useful beasties to me.
>
> Paul:
>
> You obviously don't belong to the right religion. ;^)
Well, my comment was meant to try to get those that swear profusely that common blocks are a
Bad Thing to explain why. I place common blocks in the same category as GOTO statements - if
used incorrectly they can lead to unbelievably bad source code that may or may not work.
However, used correctly and judiciously they can greatly simplify the code - for both the
programmer and subsequent user/readers. Having dealt with particularly blech f77 code replete
with common blocks (anonymous, named, different lengths, etc.) I can sympathise with those that
despise common blocks but, to use a building analogy, it's not the hammer's fault when the
framing for the house falls down....
> Seriously, I also use common blocks. I use them because:
>
> 1. They're easy, and get the job done.
I even use them in Object programs!!! :o)
> The main objections to common blocks have been:
>
> 1. Sloppy programming can cause problems, if different programs have different
> versions of the common block. That's pretty easy to get around, though.
> Typically, I use include files, so that all programs have exactly the same
> common blocks.
No argument there, but sloppy programming can cause problems regardless of what construct one
uses to manage variables, memory, etc. Pointers are what come immediately to mind..... with
objects a close second.
paulv
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|
Re: can i place a job advert [message #28129 is a reply to message #28126] |
Mon, 26 November 2001 08:24   |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
Paul van Delst <paul.vandelst@noaa.gov> writes:
> "Pavel A. Romashkin" wrote:
>>
>> Oh, people have done much worse things here and got away with it. Like
>> admitting to using common blocks. Go ahead...
> Wot's wrong with common blocks? They seem like quite useful beasties to me.
Paul:
You obviously don't belong to the right religion. ;^)
Seriously, I also use common blocks. I use them because:
1. They're easy, and get the job done.
2. Not everything is a widget program!!!
3. Even in widget programs, they can be used to maintain information after the
widget program has been killed.
The main objections to common blocks have been:
1. Sloppy programming can cause problems, if different programs have different
versions of the common block. That's pretty easy to get around, though.
Typically, I use include files, so that all programs have exactly the same
common blocks.
2. In widget programs, common blocks restrict you to only one copy of the
widget at any one time. I think this is sometimes overemphasized, but is
certainly a true disadvantage.
William Thompson
|
|
|
|
|
Re: can i place a job advert [message #28136 is a reply to message #28134] |
Mon, 26 November 2001 04:48   |
Robert Stockwell
Messages: 74 Registered: October 2001
|
Member |
|
|
Pavel A. Romashkin wrote:
> Oh, I did not tell anybody. My own little program (Display) uses Common
> because, like you said, there's no other way to communicate a *totally*
> independent object in IDL.
I'm just mentioning this in lieu of getting real work done
this early in the morning, but I fake a singleton object in
IDL in the following way.
I use a system variable to hold the object, and in
a init procedure, I check to see if the sys var is
defined, and if not I define it. Of course, that merely
changes the line 'Common name,blah1 blah2' to 'initobject',
in each routine you use, but hey, its not a common block. :)
Cheers,
bob
|
|
|
|
|
|
|
Re: Commons, Was: can i place a job advert [message #28217 is a reply to message #28126] |
Mon, 26 November 2001 11:21  |
Richard Younger
Messages: 43 Registered: November 2000
|
Member |
|
|
Paul van Delst wrote:
>
> Well, my comment was meant to try to get those that swear profusely
> that common blocks are a Bad Thing to explain why. I place common
> blocks in the same category as GOTO statements - if used incorrectly
> they can lead to unbelievably bad source code that may or may not
> work.
Well, the snooty Computer Science answer to this is that common blocks
or global data completely separate the context of the data from its
content. Similarly, with GOTOs, it's easy to separate the context of
one snippet of code from another. When you have a global variable, you
(the indefinite you, which could actually include someone else :-) )
have no real idea what sort of code is using that data. I think the
idea of prohibiting them is to remove the chore and responsibility of
keeping track of the context from anyone else (or any other process of
yours) that wanders along. It's a Good Thing(tm) when the programming
system you use discourages methodologies that tend to cause confusion
and mistakes.
Admittedly, common blocks have some features apart from purely global
data that discourage errors. They have to be specifically invoked, can't
be resized (upwards), and usually IDL projects aren't so big that one
person can't keep track of a set of well controlled commons. The
examples given why commons in IDL specifically are bad seem to involve
doing multiple things at the same time, or with multiple copies of the
same program running.
For myself, I seem to get along nicely without commons. Instead, I
generally use objects, which can carry lots of data implicitly while
still keeping them in context for many routines. The only application I
have thought seriously about using common blocks is a global hardware
lock on some I/O hardware. Even then, I could use a file, since I don't
need to access the lock often. I don't do nearly as much heavy-duty
object graphics (I'm still in line to buy that book when it comes out,
David!) or widgeting as many on this group, though.
Mind you, I'm not supporting banning commons as dogma, but I think there
are enough general objections to them to ask people to think a bit
before they rush out and use them everywhere they can.
Best,
Rich
--
Richard Younger
|
|
|