Hungarian Notation Prefixes


#1

I’m presently working through the SNAP-SCM-CAN2b CAN Bus integration guide. However, I am having a hard time comprehending what all the variable names mean. Is there a standard list of the different Hungarian Notation prefixes? Some are obvious (like ‘n’ to represent an integer or ‘nt’ to represent an integer table), but at other times it all degenerates into alphabet soup.

Is there a standard list Opto 22 uses?

Kind Regards
Bart


#2

Hi Bart,

In theory, we’d stick to our own suggestions, as documented in the [B]PAC Control User’s Guide[/B], although I can see I don’t always do that (usually I use [B]ch [/B]vs. [B]cmh [/B]for comm handles, and sometimes preface global tag names with a chart-specific prefix):


You can see from [B]this discussion[/B] how naming conventions can be a matter of personal style.

You may also want to check out [B]this document, form 2073[/B], for more Best Practices and thoughts on naming conventions.

-OptoMary


#3

Thanks for that info. I was looking for that info in the wrong guide.

Personally, I do not use ‘Hungarian’ prefixes as a rule unless there is some aspect about the variable’s function and semantics that cannot be inferred from its original type alone, or the prefix adds useful extra information. Of those that you showed, the most likely ones I would use would be the timer prefixes and perhaps the prefixes related to points and handles.

I guess that I am also used to strongly typed languages. On a slightly related note: will OptoScript eventually allow for local variables? It can be a pain not having them though on the other hand it does cut out a lot of bugs related to memory management.

Thanks, Bart


#4

Hi Bart,

You can use subroutines if you’d like to have local variables. Just pass in the global parameters you need. Check out [B]this post[/B] for more than you ever wanted to know about subroutines.

On naming those global variables–often I’ll use a prefix to my variables for a particular chart to avoid the problem of accidentally using a global in more than one chart at the same time.

For example, I’ve been writing a little strategy for some nifty cheap Belkin WeMo devices to control an outlet via WiFi with my smartphone using groov Server for Windows & SoftPAC (on my PC). Ditto some nifty wireless color-changing light bulbs (Philips hue). So all the variables in the WeMo chart look like: WEMO_nOnOff vs. the variables in the hue chart that have names like: HUE_nLightIndex.

Fun stuff!

-OptoMary