Reviewing code...
-
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :) -
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :)I once came upon a huge line that contained about 15 nested if then else statements. Not only was it ugly, it was very inefficient. Horrid little bit of code, but it worked, although owing to the nature of what it was doing, a simple Case would have been infinitely preferable. There was no reason to do it that way, and I told myself off!
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :) -
I once came upon a huge line that contained about 15 nested if then else statements. Not only was it ugly, it was very inefficient. Horrid little bit of code, but it worked, although owing to the nature of what it was doing, a simple Case would have been infinitely preferable. There was no reason to do it that way, and I told myself off!
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
I cannot deny that I have been guilty of such code sins, sometimes I write less than efficient code as I fire through a problem, but I dont think I've ever written redundant code like the example I found. Set a variable to a zero-length string, then on the very next line check it is a zero-length string... hahaha
-
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :) -
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :)For writing ASP style code in ASP.NET, that code monkey would be shot!
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
I cannot deny that I have been guilty of such code sins, sometimes I write less than efficient code as I fire through a problem, but I dont think I've ever written redundant code like the example I found. Set a variable to a zero-length string, then on the very next line check it is a zero-length string... hahaha
I think it is sensible, you never know when the value of Zero changes! :)
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
You need the coding horrors forum I beleive. And I can't read the whole right hand side of your post anyways.
It really struggles with the 16 spaced TAB characters :) The poor donkey probably have it setup so TAB's == 1 space in it's editor.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
You need the coding horrors forum I beleive. And I can't read the whole right hand side of your post anyways.
-
For writing ASP style code in ASP.NET, that code monkey would be shot!
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
For writing ASP style code in ASP.NET, that code monkey would be shot!
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
Cheers for the pointer. Was only posted in the lounge as I was sharing general chit-chat we were having about it in the office. Will post correctly in future :)
-
Don't worry about it, it appears to have generated a lot of traffic so that would suggest it is perfectly adequete post for the lounge. My mistake.
-
An old-skool legacy im trying to get rectified. But its a large code-base, and wont get changed overnight :) Personally use C# in all my "pet-projects" but have to stick to VB at the office. Worth sharing, just to make people cringe, but we still have a business critical application (used daily and directly linked to our revenues) that was written in VB 6 over 12 yrs ago... still going... Dont have the time to re-write it at the moment, and if it aint broke, dont fix it... :)
-
I think it is sensible, you never know when the value of Zero changes! :)
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
An old-skool legacy im trying to get rectified. But its a large code-base, and wont get changed overnight :) Personally use C# in all my "pet-projects" but have to stick to VB at the office. Worth sharing, just to make people cringe, but we still have a business critical application (used daily and directly linked to our revenues) that was written in VB 6 over 12 yrs ago... still going... Dont have the time to re-write it at the moment, and if it aint broke, dont fix it... :)
-
I cannot deny that I have been guilty of such code sins, sometimes I write less than efficient code as I fire through a problem, but I dont think I've ever written redundant code like the example I found. Set a variable to a zero-length string, then on the very next line check it is a zero-length string... hahaha
-
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :)Have fun :)
List<List<urlKeeper>> PhraseResultSet = new List<List<urlKeeper>>();
c.Urls = u.AltavistaScrapper(c.Url);
for (int i = 0; i < uniqueKeywords.Count; i++)
{
PhraseResultSet.Add(u.AltavistaPhraseScrapper(uniqueKeywords[i]));// get ranking for comps c.Competitors.FindAll(delegate(Competitors x) { return uniqueKeywords\[i\] == x.Phrase; }).ForEach(delegate(Competitors x) { PhraseResultSet\[i\].Sort(new Comparison<urlKeeper>(delegate(urlKeeper obj1, urlKeeper obj2) { return obj1.Rank.CompareTo(obj2.Rank); })); int index = PhraseResultSet\[i\].FindIndex(delegate(urlKeeper y) { return (y.HostName.ToUpper().Replace("HTTP://", "") .Replace("HTTPS://", "") .Replace("WWW.", "") == x.Url.ToUpper().Replace("HTTP://", "") .Replace("HTTPS://", "") .Replace("WWW.", "")); }); if (index >= 0) x.Rank = PhraseResultSet\[i\]\[index\].Rank; else x.Rank = -1; }); ; }
-
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :)Often such strange things are the result of tweaking the code until it finally worked and not taking the time to clean up the debris from all this trial and error.
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
-
I often find myself having to review code within all of our systems as our company grows/changes, as im sure most of us have to during the course of work. Sometimes I find myself looking at old code, and feeling embaressed for the coder (who is sometimes myself) as code that was applicable due to knowledge at the time looks frightful in the light of newer knowledge and skills, but occasionally I come across absolute gems. The coder who wrote this (who shall remain unamed) is no longer with the company, but I do not regret the loss one bit in the face of massive amounts of code being uncovered of this stunning calibre; Classic ASP:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("btnAddTask") <> "" Then
For Each obj In Request.FormiSectionID_New = ""
If Len(iSectionID_New) = 0 Then
iSectionID_New = Trim(Request.Form("section_id_filter"))
End IfiTaskID_New = ""
If Len(iTaskID_New) = 0 Then
iTaskID_New = Trim(Request.Form("task_new"))
End IfiDisplayOrder_New = ""
If Len(iDisplayOrder_New) = 0 Then
If Len(Trim(Request.Form("display_order_new"))) > 0 And IsNumeric(Trim(Request.Form("display_order_new"))) Then
iDisplayOrder_New = Trim(Request.Form("display_order_new"))
End If
End IfiActionOrder_New = ""
If Len(iActionOrder_New) = 0 Then
If Len(Trim(Request.Form("action_order_new"))) > 0 And IsNumeric(Trim(Request.Form("action_order_new"))) Then
iActionOrder_New = Trim(Request.Form("action_order_new"))
End If
End If
Next
End if
End ifthe bold sections are the ones that immediately drew the attention of the team, but we then looked at the logic itself, and were stunned by the loop itself
For Each obj In Request.Form
which not only is never used, but just increases the number of iterations of the same code for absolutely no reason whatsoever... Anyone else have the joy of such discoveries?? Any clangers found that left you slack-jawed and slightly disoriented?? :) :)I'm astounded that people will criticize code, but make spelling mistakes during their public diatribe ("embaressed").
GC