View Single Post
  #10 (permalink)  
Old February 2nd, 2010, 09:39 PM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I know I'm being a curmudgeon about this, but this is such a wonderful example of what a pile of [censcored] that DW is that I have to pick on it.
Code:
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
Because of the "true" there, the IF test will *ALWAYS* go to the THEN part. So if you hit this line, MM_grantAccess *will* be true.

Now, if DW was smart enough to KNOW that this site/page isn't using MM_UserAuthorization, then WHY COULDN'T it be smart enough to collapse this IF test out of existence???

And so then we can start collapsing more code:
Code:
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="0,1"
MM_authFailedURL="../content/online.htm"
MM_grantAccess=false
If Session("MM_Username") <> "" Then MM_grantAccess = true
If Not MM_grantAccess Then
...
And then collapse again:
Code:
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="0,1"
MM_authFailedURL="../content/online.htm"
MM_grantAccess= (Session("MM_Username") <> "" )
And again... well, you get the idea. Even a *tiny* bit of code analysis would have permitted the DW people to collapse that all down to this:
Code:
<%
' *** Restrict Access To Page: Grant or deny access to this page
If Session("MM_Username") = "" Then
  MM_referrer = Request.ServerVariables("URL") & "?" & Request.QueryString()
  Response.Redirect "../content/online.htm?accessdenied=" & Server.URLEncode(MM_referrer)
End If
%>
Which I would have considered reasonable.
Reply With Quote