Hi Michael,
I personally agree with you. It's allways a good practice to use a
prefix. The hungarian notation in good old c times was very usefull. Why
not give the variable a type implicitly (even though MM doesn't know
types, except for those coming from java).
For instance Variables.sName, or Variable.fSalary for a string and a
float variable. The code can be easally read. You allways know in which
scope a variable is located and what data it is supposed to contain.
And it is a huge performance boost, if you prefix all your variables
with the scope their in. As already mentioned in a previous post, CF
doesn't have to check the existing scopes to find the variable.
We at railo have designed a handy approach. You can force the developer
to use scope-prefixes if you define the setting "scope cascading" to
"strict" in your railo.xml. This means that you have to define the scope
of your variable, or an exception will be raised. Here an extract of a
post dated a couple of weeks ago.
<start quote>
Well exactly spoken in railo you can configure scope cascading in the
following way: Extract of the railo.xml:
<!--
scope configuration:
cascading (expanding of undefined scope)
- strict (argument,variables) Means that railo
only checks argument and variables scope for the variable
- small (argument,variables,cgi,url,form)
- standart
(argument,variables,cgi,url,form,cookie)
cascade-to-resultset: yes|no
when set to yes, railo allows inside a <cfoutput
query="queryname"> and <cfloop query="queryname"> to call columns of the
resultset implicitly
merge-url-form:yes|no
when set to yes all form and url variables are
merged into both scopes
-->
<scope
cascading="standart"
cascade-to-resultset="yes"
merge-url-form="no">
</start quote>
Hope it helps.
<cfgreetings from="[EMAIL PROTECTED]" to="reader" location="bern"
country="switzerland" function="railo core developer" message="merry
xmas">
-----Urspr�ngliche Nachricht-----
Von: Michael Dinowitz [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 24. Dezember 2004 04:10
An: CF-Talk
Betreff: Re: Prefixing local variables
The point of this is not what you or I would use. It's designed to
'force'
people to localize their variables. If they did what was right, then
this
would not be needed. As most people do not localize their vars, I'm
trying
to create a psychological 'reminder' for them.
There is a difference between the code you use locally and the code you
provide to others. For others you have to teach, train, and yes, even
manipulate to get them to do what's right. $variable is as 'loud' a
statement of localization that I can think of.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - CFDynamics
http://www.cfdynamics.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188737
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54