On Aug 24, 12:41 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> Are you familiar with the difference between Apps Hungarian and Systems
> Hungarian?
Not officially, see next comment. :-)
> Apps Hungarian uses the prefix to tell you something interesting and useful
> about the *purpose* of the variable. Systems Hungarian follows strictly the
> low level data type. Many Apps Hungarian enthusiasts (like me) consider
> Systems Hungarian to be a Bad Thing.
Oh I see, so from the old debates, someone eventuallly gave them
distinctive terms.Ok, sure, I know the difference. just not
"officially." Now I do, thanks. :-)
> Depends on the context.
Agreed.
> I'm a big fan of "i" and "n", but I wouldn't use them like that.
It depends on the context. :-)
At the end of the day, its about understanding code, readability and
context.
> for( var i = 0, n = someArray.length; i < n; ++i ) {
> }
as most experienced codes do with the i-n concept, but lets throw this
in:
for( var row = 0, n = maxRows; row < maxRows; ++row ) {
for( var col = 0, n = maxColumns; rows < maxColumnss; +
+col ) {
}
}
People can read this loop and immediately apply it to something
dealing with tabular concept.
As you know, some languages can also iterate on non-numerics,
for letter = "A" to "Z"
next
and for languages that support "each"
foreach person in addressBoook
next
What I often do to use acronyms, such as:
TwcNodeInfo ni; // nodeinfo
if (GetNodeInfo(ni)) {
}
> Or when there is more than one thing:
>
> for( var iRow = 0, nRows = rows.length; iRow < nRows; ++iRow ) {
> var row = rows[iRow];
> for( var iCol = 0, nCols = row.cols.length; iCol < nCols; ++iCol ) {
> var col = cols[iCol];
> }
> }
>
> In that code, when I see iRow and nRows vs. iCol and nCols, I know right
> away which are the related values and what they contain.
HA!!! You and I think like! I was going to just delete what I wrote
above and just concur with you here, but I left it in to illustrate
the elegance of common technical "Natural Elements of Style" that are
long established and still useful today. :-)
> > In JS, we already have a few pseudo-standard nomemclature,
> > for example a popular patten of starting functions with a
> > lowercase letter:
>
> > function initProcess()
>
> > I personally prefer using capitalized words for
> > processes/functions and lower case words for data.
>
> Don't!
Yeah, I know. :-)
> And finally, to bring this on topic :-) here is a jQuery-specific naming
> convention that I highly recommend. Use an initial $ on every variable that
> contains a jQuery object:
Yes, an excellent jQuery Hungarian Notation recommendation. :-)
The key concept is "contains (or returns) a jQuery object." You
certainly do not want to get in a habit of doing this:
var $n = $.(selector).length;
--
HLS