I think you ought to use variable names that sufficiently communicate
what they store, without the need to explicitly supply type
information.  That goes regardless of whether you're using a strongly
or loosely typed language.  I.e. if you have a collection, it
shouldn't be singular, unless it's a singular collection.  For example
"personList" pretty much guarantees you've got an array of structs,
and array of CFC instances, or a recordset.  I don't find the
remaining ambiguity much of a burden - certainly not sufficient to
require some ugly prefixes.  Things like customerIdList, though they
are a collection, pretty much guarantees a delimited string (a CF
list) containing ID values.  So "list" is used in both cases, but the
semantics of what the list contains dictates what type of storage is
reasonable.

If you want to use Hungarian notation to delineate states or something
(validated/unvalidate), that's a different topic.  With CF, I prefer
using containers to do that differentiation (url/form/attributes is
never to be trusted, for example).

Some languages have explicit support for "tainted" variables which use
compiler checks to ensure you're not potentially shooting yourself in
the foot by trusting a tainted variable.  Because the compiler is
explicitly forcing the distinction without any syntactic construct, HN
can provide a way to express the taintedness with a code-readable
structure (i.e. a syntax).

Then there's the one-letter variable names.  If you see a variable
named 'i', 'j', 'k', 'm', or 'n' in my code, you can rest assured that
it's an integer loop index of some kind, and all the previous letters
are also in context at that point.  If you see an 'a', it's an array,
probably per-iteration within a loop.  And if you see an 's', it's a
struct, again likely per-iteration within a loop.  Here's what I mean
by per-iteration within a loop:

<cfset result = [] />
<cfloop from="1" to="#something#" index="i">
  <cfset s = {} />
  <cfset arrayAppend(result, s) />
  <cfset s["..."] = ... />
  ...
</cfloop>

<cfloop from="1" to="#arrayLen(result)#" index="i">
  <cfset s = result[i] />
  #s["..."]#
  ...
</cfloop>

cheers,
barneyb

On Tue, Sep 16, 2008 at 10:30 AM, Brian Sadler <[EMAIL PROTECTED]> wrote:
>
> Apologies if this has been done to death before but...
>
> Whilst reviewing some code written by a colleague, my hackels were
> raised by the presence of HN gems such as arr_str_mimeattach (to
> signify an array of structures called mmimeattach apparently).  Am I
> alone in finding this stuff abominable?
>
> However, I've been quite happy to use things like qryGetCustomer and
> customerIdList which opens me up to the gravest of charges of being
> hypocritical...
>


-- 
Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to