Now, you might be wondering, what does he mean, Don't skimp on the variables? Well, often times it is more
efficient to use variables to store results from ADO queries or from objects, and then reference the
variable as opposed to continuously referencing the object.
For example, you could do this:
If Request.QueryString("Name") = "Frank" Then
...
End If
If Request.QueryString("Name") = "Steve" Then
...
End If
Response.Write("Your name is " & Request.QueryString("Name"))
Each time you use the Request object, ASP has to go read the QueryString variable name. You can reduce
this to having to just read this once by doing the following:
Dim strName
strName = Request.QueryString("Name")
If strName = "Frank" Then
...
End If
If strName = "Steve" Then
...
End If
Response.Write("Your name is " & strName)
Plus, I personally think the above scenario is easier to read. It's easier, I think, to mentally associate
strName to be the user's name as opposed to associating Request.QueryString("Name") as the user's name.
Just my two cents, though!
efficient to use variables to store results from ADO queries or from objects, and then reference the
variable as opposed to continuously referencing the object.
For example, you could do this:
If Request.QueryString("Name") = "Frank" Then
...
End If
If Request.QueryString("Name") = "Steve" Then
...
End If
Response.Write("Your name is " & Request.QueryString("Name"))
Each time you use the Request object, ASP has to go read the QueryString variable name. You can reduce
this to having to just read this once by doing the following:
Dim strName
strName = Request.QueryString("Name")
If strName = "Frank" Then
...
End If
If strName = "Steve" Then
...
End If
Response.Write("Your name is " & strName)
Plus, I personally think the above scenario is easier to read. It's easier, I think, to mentally associate
strName to be the user's name as opposed to associating Request.QueryString("Name") as the user's name.
Just my two cents, though!
相关信息
- 关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 管理登陆
- Copyright © 2003-2007 ZhuYe123.COM. All Rights Reserved . 粤ICP备05072659号
- 致力于中国个人网站发展,我们一直在努力!