Page 1 of 1

Plugin Variable Notation

Posted: 25 Aug 2011 18:27
by tatewise
The Help for The Family Historian API defines a 'Hungarian' notation for parameters.
i.e.
ptr = pointer object
dt = date object
dp = date-point object
str = text string
i = integer
b = boolean (true or false)
tbl = Lua table of values
However, the Sample Plugin Scripts do not always adhere to this notation.
e.g.
Some pointer objects are simply pi or pf.
Some text strings start with s instead of str.
Some variables do not use the notation at all.

The IUPLUA GUI builder examples tend to use similar notations for its data types.

1) Should the FH API Sample Plugin Scripts be improved to use its notation more faithfully?

2) Should LUA scripts use a similar notation as good style, even where not using the FH API?

3) Should Knowledge Base LUA code snippets follow a similar style guide?

If so perhaps a few more 'Hungarian' prefixes are needed.
e.g.
num or fp = floating point number
etc...

ID:5409

Plugin Variable Notation

Posted: 28 Aug 2011 10:13
by tatewise
A few more thoughts...

Personally I prefer the prefix int to i and boo or bln or flg to b.

Also any function that returns a value should use a similar 'Hungarian' prefix.

To aid understandability and debugging, I suggest that intentionally global variables (and global functions) should start with a capital letter.
e.g.
Ptr, Str, Int, etc...