Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Now this is bad....

Now this is bad....

Scheduled Pinned Locked Moved The Weird and The Wonderful
21 Posts 18 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E emartinho

    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 String

    Dim 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
    
    Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #2

    What the... :omg: :wtf:

    It's an OO world.

    1 Reply Last reply
    0
    • E emartinho

      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 String

      Dim 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
      
      R Offline
      R Offline
      Rajesh Anuhya
      wrote on last edited by
      #3

      :confused: :omg: :wtf:

      Rajesh B --> A Simple Programmer <--

      1 Reply Last reply
      0
      • E emartinho

        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 String

        Dim 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
        
        T Offline
        T Offline
        TorstenH
        wrote on last edited by
        #4

        :laugh: This is one clear line of commands. You can't say the programmer wanted to confuse you! regards Torsten

        I never finish anyth...

        1 Reply Last reply
        0
        • E emartinho

          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 String

          Dim 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
          
          B Offline
          B Offline
          Bernhard Hiller
          wrote on last edited by
          #5

          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.

          _ W 2 Replies Last reply
          0
          • E emartinho

            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 String

            Dim 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
            
            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #6

            zee googles, zey do nuthing.

            1 Reply Last reply
            0
            • E emartinho

              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 String

              Dim 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
              
              F Offline
              F Offline
              fjdiewornncalwe
              wrote on last edited by
              #7

              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.

              1 Reply Last reply
              0
              • E emartinho

                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 String

                Dim 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
                
                P Offline
                P Offline
                Paladin2000
                wrote on last edited by
                #8

                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|

                1 Reply Last reply
                0
                • B Bernhard Hiller

                  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.

                  _ Offline
                  _ Offline
                  _Erik_
                  wrote on last edited by
                  #9

                  I guess he would be able to retire after this one...

                  1 Reply Last reply
                  0
                  • E emartinho

                    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 String

                    Dim 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
                    
                    A Offline
                    A Offline
                    AspDotNetDev
                    wrote on last edited by
                    #10

                    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.

                    L 1 Reply Last reply
                    0
                    • A AspDotNetDev

                      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.

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #11

                      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.

                      A 1 Reply Last reply
                      0
                      • E emartinho

                        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 String

                        Dim 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
                        
                        B Offline
                        B Offline
                        BillW33
                        wrote on last edited by
                        #12

                        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.

                        E 1 Reply Last reply
                        0
                        • B BillW33

                          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.

                          E Offline
                          E Offline
                          emartinho
                          wrote on last edited by
                          #13

                          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

                          B 1 Reply Last reply
                          0
                          • L Luc Pattyn

                            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.

                            A Offline
                            A Offline
                            AspDotNetDev
                            wrote on last edited by
                            #14

                            Thanks... that's, uh, comforting. :rolleyes:

                            Chris Maunder:

                            Fixign now.

                            1 Reply Last reply
                            0
                            • E emartinho

                              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

                              B Offline
                              B Offline
                              BillW33
                              wrote on last edited by
                              #15

                              I am not at all surprised that the original code was not nicely formated. Which means that the original code had no redeeming features. X|

                              Just because the code works, it doesn't mean that it is good code.

                              1 Reply Last reply
                              0
                              • B Bernhard Hiller

                                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.

                                W Offline
                                W Offline
                                walterhevedeich
                                wrote on last edited by
                                #16

                                Dirty Consultant Trick # 8?[^] :laugh: :laugh: :laugh:

                                Ignorance of the ability brings disability.

                                1 Reply Last reply
                                0
                                • E emartinho

                                  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 String

                                  Dim 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
                                  
                                  R Offline
                                  R Offline
                                  Richard A Dalton
                                  wrote on last edited by
                                  #17

                                  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.

                                  1 Reply Last reply
                                  0
                                  • E emartinho

                                    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 String

                                    Dim 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
                                    
                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #18

                                    ... 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

                                    1 Reply Last reply
                                    0
                                    • E emartinho

                                      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 String

                                      Dim 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
                                      
                                      V Offline
                                      V Offline
                                      Vladimir Svyatski
                                      wrote on last edited by
                                      #19

                                      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? :)

                                      1 Reply Last reply
                                      0
                                      • E emartinho

                                        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 String

                                        Dim 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
                                        
                                        A Offline
                                        A Offline
                                        Albert Holguin
                                        wrote on last edited by
                                        #20

                                        wow :omg: :wtf:

                                        1 Reply Last reply
                                        0
                                        • E emartinho

                                          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 String

                                          Dim 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
                                          
                                          R Offline
                                          R Offline
                                          Ravi Sant
                                          wrote on last edited by
                                          #21

                                          :wtf: He must be suggested to join anti-if campaign.

                                          // ♫ 99 little bugs in the code, // 99 bugs in the code // We fix a bug, compile it again // 101 little bugs in the code ♫

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups