[Gambas-user] Better use of prefixes
Cedron Dawg
cedron at exede.net
Sat Mar 16 17:53:40 CET 2019
As I said in my previous reply, Hungarian isn't as beneficial as it is touted. What is more important when looking at code is knowing where the variable is defined and thus its scope.
That's what I use prefixes for. Here is my current set:
=========
Property/Variable Prefixes
---------
(none1) Simple local variables, e.g. i, x, N, etc.
(none2) Gambas Property Declaration
(none3) Subroutine Names
the Within a Sub
My Public - Within a Class
my (or $my) Private Property/Variable
Arg Argument in Public Routine
arg Argument in Private Routine
Ret Updatable Argument in Public Routine
ret Updatable Argument in Private Routine
Our Static Public Property/Variable
our ($our) Static Private Property/Variable
=========
The only one you guys use is "$", so I included it for kicks though it is redundant with my and thus qualifies as an uglifier. Though its utility is unquestionable. Now expand that to this set.
This prefixing system is way way way more useful than Hungarian.
Combine with good suffixing indicating the kind of variable which generally implies the type:
e.g. myPostCount
my = private class variable
Post = the actual thing
Count = "Count of" implying integer
e.g. myPostIndex
e.g. MyLastName
The additional benefit of this system is that it avoids almost all name collisions with system names and makes global search and replaces a lot less error prone.
More information about the User
mailing list