In trying to learn can you help me understand the naming conventions.
- in Const ws & ranges - ks << why ks ?
- in Const filter - ki << why ki ??
Hi, PaulF!
Thanks for your kind words, hope the new times would be fine for your boss, otherwise tell him to give me a call.
The notation stuff. Once upon a time...
All this began when in the early 80's the personal computer come to this world and users wanted to spreadsheet, even if they didn't know exactly what it was. Before that there was only @
Hui tapping with Visicalc & Multiplan on CP/M systems.
PC's came come with interpreted Basic (beginner's all-purpose symbolic instruction code) in ROM (i.e, chipped) as only available language. Ok, assembler too but every computer have always had it.
Soon, in '83 Lotus 1-2-3 appeared, it had macros but not a real programming language, then Quattro occupied the throne for a bit and then MS came out with Excel 2.0, '87 I think, the funny thing is that's never been a 1.0. But it was until early 90's that Basic joined worksheets with Excel 5.0 in the form of VBA.
From the earliest times of the interpreted versions Basic language supported suffixes for explicitly defining types of variables:
% real, & long, @ decimal, ! single, # double, $ string
https://docs.microsoft.com/en-us/do.../language-features/data-types/type-characters
There was no suffix for other data types like boolean, date and others.
Programmers didn't much agree with this cryptic suffix identification system and a guy from Xerox came out with the Hungarian Notation:
https://en.wikipedia.org/wiki/Hungarian_notation
There are many variations of this but mainly it dedicated generally 3 letters as prefix to identify variables and objects:
int for integer, lng for long, str for string, dbl for double, dec for decimal, dat for date, bol for boolean and so on.
Then someone said "hey, what to do with control names?", as the idea was that looking only at the code one would find out what was that name/word representing or referencing, and Redmond guys always ready for helping the developer's community suggested this:
https://msdn.microsoft.com/en-us/library/aa263493(v=vs.60).aspx
txt for text box, cbo for combo, lst for list...
So if you happened to find something like:
txtSomething.Text=strAnotherThing
you could easily realize that the string variable representing AnotherThing was being assigned to the text control that held the value of Something.
In my particular case, I joined immediately both Hungarian and Redmondarian suggested conventions as I was tired/bored/displeased when having to modify not only other people code but older mine's too! What would I have intended to mean with this?:
A.Caption=S
WTF were A & S? Maybe the week when I wrote it I could remember that, but surely not next month.
For serious projects (yes, not all projects are serious, come on!) or when there are client requirements I stick to the 3+3 notation conventions and I always assign significant names.
For projects where code is short (Chandoo's posts) I use a personal shrinked variation of them:
a) 1 letter prefix for variables (s string, i integer, l long, d date/double -dt date, db double, if both-, b boolean, v for variant...)
b) 3 letters prefix for objects (txt text box, rng range, ws worksheet, wb workbook...)
c) 1 pre-prefix letter for constants (yeah, my rule, not in both below notations): k
ki for integer, ks for string, kd for date...
d) 1 pre-prefix for global (used at module level instead of procedure level): g
gi for integer, gs for string, gki for global integer constant, gks for global string constants...
e) 1 pre-prefix for parameters (as arguments definitions): p
pi for integer, ps for string, ...
So if I (or you or the person who dares to accept sample codes from me and even more dangerously to use them) find something like:
gsNounDenotingSomething = psNounComingFromWhoKnows
iBottle=gkiBottlesAsDefault
then there is a string parameter being stored in a global string variable in the 1st example, and a global integer constant being assigned to an integer variable.
Hope it helps. Feel free to ask anything else... except about the prehistorical ages of Visicalc/Multiplan... you yet know whom to address to!
Regards!