[thelist] if...or...then in asp

Warden, Matt mwarden at mattwarden.com
Mon Feb 25 15:42:01 CST 2002


On Feb 25, David at softv.net had something to say about RE: [thelist]...

>Another nit-pickety sorta thing is that you should always use explicit
>object references. If you simply use Request("item"), the ASP engine has to
>iterate trough all of the Request object collections till it finds a match,
>starting with the Server Variables, which incur a not-trivial performance
>hit. Use:
>
>Request.Form("item")
>Request.QueryString("item")
>Etc...

speaking of nit-pickety...

i hate the word "always"

using the Request("field") form has a good number of valid uses.

for instance, i'd rather have:

<%
sVar = trim(Request("var"))
%>

than:

<%
sVar = trim(Request.Form("var"))
if sVar = "" then
	sVar = trim(Request.QueryString("var"))
end if
%>

and that's just one variable. also, there are potentially situations where
the value could come from a cookie as well. so, you'd actually have
another if-then-else in the second code example.

granted, a programmer not explicitely citing the collection needs to be
careful so they dont' get valuea from the form collection when they want
valueb from the queystring collection with the same key.

sure, in general, it's better to explicitely name the collection to be
searched. and that's a great point. but there are always
(heh) exceptions. and there are exceptions to that too. er...


--
mattwarden
mattwarden.com




More information about the thelist mailing list