Re: Is there any conventions style programming IDL? [message #39074] |
Sun, 25 April 2004 00:32  |
Paul Sorenson
Messages: 48 Registered: May 2002
|
Member |
|
|
"Dick Jackson" <dick@d-jackson.com> wrote in message
news:KNcic.223564$Pk3.78786@pd7tw1no...
>
> I agree with Mike Wallace in general, but I find it useful to identify
> two kinds of identifiers in special ways: objects and pointers. I do
> this since we work with them in ways quite different from the other
> types. For example, when I see variable pInfo, the 'p' reminds me that I
> need to dereference with '*' before using the thing itself.
>
Yeah. What he said. Objects and pointers.
-Paul Sorenson
www.paulsorenson.com
|
|
|
|
Re: Is there any conventions style programming IDL? [message #39088 is a reply to message #39086] |
Fri, 23 April 2004 10:56   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"Michael Wallace" <mwallace_spam@spam.swri.edu.invalid> wrote in message
news:108h4fvomj43c49@corp.supernews.com...
>
> Dick Jackson wrote:
>
>> Mike Schienle has this available on the web:
>> http://www.customvisuals.com/IDL_Style.html
>
> This document combined with a couple of tips from David make a good
set
> of rules to follow. There are a couple things I think I'll adopt into
> my personal style. However, I have to disagree with the use of
> Hungarian notation. IDL is a weakly-typed, dynamic language and
> enforcing Hungarian rules removes some of the benefits of such a
> language. I don't have the time now to get into the details, but I
see
> it as more of a hindrance rather than a help.
>
> Hungarian notation is not suited to weakly-typed dynamic languages
such
> as IDL, Python or Perl or object-oriented languages such as Java or
C++.
> Hungarian notation does have it's place in the strongly-typed
> procedural languages like good ol' C. I actually use Hungarian
notation
> a lot when doing C -- it makes casting and variable type mistakes so
> much easier to catch.
>
> -Mike
For those who are wondering (like I was) "Hungarian Notation" refers to
what Mike Schienle suggests, as in:
Variables of type Byte shall begin with the letter "b"
A full description of this and other aspects of naming identifiers is
this article at Microsoft's MSDN site:
http://tinyurl.com/ezmr
I agree with Mike Wallace in general, but I find it useful to identify
two kinds of identifiers in special ways: objects and pointers. I do
this since we work with them in ways quite different from the other
types. For example, when I see variable pInfo, the 'p' reminds me that I
need to dereference with '*' before using the thing itself.
Just my CAD 0.02 (two Canadian cents' worth)
Cheers,
--
-Dick
Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
|
|
|
Re: Is there any conventions style programming IDL? [message #39093 is a reply to message #39088] |
Fri, 23 April 2004 01:52   |
Esteban Garc�a Cues
Messages: 7 Registered: April 2004
|
Junior Member |
|
|
No I don't have problems whit criticism , I only hope you won't have
problems whit spanish ;-)
(You have to understand me because I'm writting the document in my
language and I dont fell to translate it, at least not now, not time).
Cheers,
Esteban Garc�a Cuesta
"David Fanning" <david@dfanning.com> escribi� en el mensaje
news:MPG.1af1d0713e280b95989729@news.frii.com...
> Esteban Garc�a Cuesta writes:
>
>> Thanks, I'm going to write a document of conventions style programming
with
>> all your
>> ideas and the ''Code conventions for the Java Programming Language'' and
>> I'll put it here to
>> know your opinions about it.
>
> I don't like it!!
>
> Oh, wait, I haven't even seen it. :-(
>
> Uh, sure, put it here. I just hope you're not the type
> of person who gets flustered by a little criticism. :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
|
|
|
Re: Is there any conventions style programming IDL? [message #39103 is a reply to message #39101] |
Thu, 22 April 2004 07:24   |
meinel
Messages: 14 Registered: February 1994
|
Junior Member |
|
|
"Esteban Garc�a Cuesta" <egc@fis.uc3m.es> wrote in message news:<c686up$a84$1@khitai.uc3m.es>...
> Hello,
> I'm trying to standarize the way we programm in IDL , is there any
> rules or conventions programming IDL ?
>
> Thanks a lot.
> Esteban Garc�a Cuesta
Only personal preferences. If you use EMACS there is a plug-in that
will take care of most pretty-fying for you.
My personal preferences for ease of readability are:
Procedures/functions/keywords all UPPERCASE
Variables all lowercase
Indent FOR loops, CASE, IF, continuation lines
Keywords on separate continuation lines
Align multiple "=" or "$" or anything else common to multiple lines
A keyword and its associated variable should have the same name
For example, call a procedure with multiple keywords:
---------------------------------------------
PLOT, hist, $
XMARGIN = [0, 0], $
YMARGIN = [0, 0], $
XSTYLE = 1, $
PSYM = 10, $
YRANGE = [0, 0.9*MAX(hist)] , $
XRANGE = [0, N_ELEMENTS(hist) - 1]
---------------------------------------------
(I don't know how this will appear on GOOGLE, but if you use a
fixed-pitch font, these lines will appear the way I described)
Multiple IF...THEN lines:
---------------------------------------------
; Defaults for keywords
IF (N_ELEMENTS(title) EQ 0) THEN title = 'New Data'
IF (N_ELEMENTS(latitude) EQ 0) THEN latitude = [0, 0, 0, 0]
IF (N_ELEMENTS(longitude) EQ 0) THEN longitude = [0, 0, 0, 0]
IF (N_ELEMENTS(filename) EQ 0) THEN filename = ''
IF (N_ELEMENTS(true) EQ 0) THEN true = 3
---------------------------------------------
Of course, if you are devious and WANT to make your distribution code
hard to read, you can remove all extra white space (all UPPERCASE
strings need whitespace) and reassign the variables with random
strings (search for lowercase strings).
Have fun!
Ed Meinel
|
|
|
|
|
|
Re: Is there any conventions style programming IDL? [message #39209 is a reply to message #39088] |
Mon, 26 April 2004 13:32  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"Dick Jackson" <dick@d-jackson.com> wrote in message
news:KNcic.223564$Pk3.78786@pd7tw1no...
>
> For those who are wondering (like I was) "Hungarian Notation" refers
to
> what Mike Schienle suggests, as in:
>
> Variables of type Byte shall begin with the letter "b"
>
> A full description of this and other aspects of naming identifiers is
> this article at Microsoft's MSDN site:
>
> http://tinyurl.com/ezmr
>
> I agree with Mike Wallace in general, but I find it useful to identify
> two kinds of identifiers in special ways: objects and pointers. I do
> this since we work with them in ways quite different from the other
> types. For example, when I see variable pInfo, the 'p' reminds me that
I
> need to dereference with '*' before using the thing itself.
>
> Just my CAD 0.02 (two Canadian cents' worth)
Mirko Vukovic asked me to forward this to the group:
-----
I find Hungarian very usefull in designating the ``role'' of variables.
That is one level higher than type. Consider the foolwing
multiple-usage of File and FileName. The hungarian notation allows (me)
a simple naming convention.
vFileName=['file.1','file.2','file.3'...]
cFile=n_elements(vFileName)
for iFile=0,cFile-1 do begin
FileName=vFileName[iFile]
...
In the above, c stands for count, i for index, v for vector. I even use
it in combinations, such as
viGoodPixel=where(mPixel eq ...,cGoodPixel)
Now, vi is a vector of pixels, and cGoodPixel is the count of good
pixels. And so it goes.
Dr.Ko
-----
|
|
|