Now this is bad....
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
That guy tricked you. He wrote a code generator (which he hides from you, and the boss) to generate such long lines of code, and thus he earns lots of money since he gets paid for lines of code.
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
See... This is what happens when a developer writes in VB for too long.. :)
I wasn't, now I am, then I won't be anymore.
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
What's worse is that this is obviously just one part of a very messy inline-SQL generation procedure... Since this would only make one part of a WHERE clause, there are no doubt similar structures elsewhere that you're not showing us... VB, plus messy inline-SQL generation... ick. X| X| X|
-
That guy tricked you. He wrote a code generator (which he hides from you, and the boss) to generate such long lines of code, and thus he earns lots of money since he gets paid for lines of code.
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
X| I can't stop dry heaving. :(( That code may be worse than my 558 Lines Of QuickBasic Glory. I can't take all this bad code! *throws up again, while :(( and trying to catch breath*
Friedrich Nietzsche wrote (proof that trolls predate online forums):
These [philosophers] always become in the end [...], perhaps without being themselves aware of it, sophisticated vengeance-seekers and poison-brewers.
-
X| I can't stop dry heaving. :(( That code may be worse than my 558 Lines Of QuickBasic Glory. I can't take all this bad code! *throws up again, while :(( and trying to catch breath*
Friedrich Nietzsche wrote (proof that trolls predate online forums):
These [philosophers] always become in the end [...], perhaps without being themselves aware of it, sophisticated vengeance-seekers and poison-brewers.
Don't feel too bad about it, yours was pretty horrible too. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
-
That is pretty horible. The only good thing about that block of code is that it is neatly formated. ;) :sigh: :laugh:
Just because the code works, it doesn't mean that it is good code.
-
Don't feel too bad about it, yours was pretty horrible too. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
Thanks... that's, uh, comforting. :rolleyes:
Chris Maunder:
Fixign now.
-
I was the one that formatted it! :laugh: You should have seen what it looked like before. I won't post it because it's way too large, but trust me, it was pretty bad! :D
-
That guy tricked you. He wrote a code generator (which he hides from you, and the boss) to generate such long lines of code, and thus he earns lots of money since he gets paid for lines of code.
Dirty Consultant Trick # 8?[^] :laugh: :laugh: :laugh:
Ignorance of the ability brings disability.
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
Eeeegads! This code is why code reviews were invented. That programmer should be forced to keep working on that until it's fixed, that way you at least contain them and stop them doing this elsewhere. If they haven't fixed it after a week, fire their ass. Whoever the developers were that let it through a code review...Fire their asses too. Of course I jest. There wasn't a code review, there never is in these situations. So fire whoever is responsible for ensuring there are code reviews. If nobody is responsible for ensuring there are code reviews, fire the person responsible for ensuring that there is a person responsible for ensuring that there are code reviews. When you've recursively made your way to the top of the Org Chart and fired everyone and the company no longer exists, this mess of code will have served it's purpose. -Rd
Hit any user to continue.
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
... where they breed such ingenious people? I have a similar thing here. Thousands of lines in one (static) method which are supposed to generate each and every database query the entire application may need. A nightnare to debug...
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011 -
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
Where did you get this stuff? :wtf: Didn't teachers in university/college tell that you need to split a job into smaller chunks like subfunctions? :)
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then
wow :omg: :wtf:
-
EDIT: This is LOOOONG. Sorry. :D The following code is used to create "WHERE" clause criteria, for all possible cominations of 8 "class" parameters if the "group_a" parameter is passed with a value. I know there's a better way of doing this, but I can't be bothered to unravel this convoluted piece of code! :laugh:
Function grpStatement(group_a As String, class_aa As String, class_ab As String, class_ac As String, _
class_ad As String, class_ae As String, class_af As String, class_ag As String, _
class_ah As String, classCondition_a As String) As StringDim groupCondition_a As String
If group\_a <> "" Then If class\_aa <> "" Then classCondition\_a = classCondition\_a & "'" & class\_aa & " %'" If class\_ab <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ab & " %'" If class\_ac <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ac & " %'" If class\_ad <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ad & " %'" If class\_ae <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ae & " %'" If class\_af <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_af & " %'" If class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ah <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ah & " %'" End If ElseIf class\_ag <> "" Then classCondition\_a = classCondition\_a & " OR Level4 LIKE '" & class\_ag & " %'" If class\_ah <> "" Then