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. Practicing the Dark Arts of Invocation

Practicing the Dark Arts of Invocation

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpquestion
18 Posts 9 Posters 1 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.
  • R Rob Grainger

    I think this just speaks for itself... (I apologise in advance for the pain caused) How many bad practices can y'all spot in this?

        Function InvokeMember(MethodName As String, \_
                Optional ByRef P1 As Object = "!%$", Optional ByRef P2 As Object = "!%$", \_
                Optional ByRef P3 As Object = "!%$", Optional ByRef P4 As Object = "!%$", \_
                Optional ByRef P5 As Object = "!%$", Optional ByRef P6 As Object = "!%$", \_
                Optional ByRef P7 As Object = "!%$", Optional ByRef P8 As Object = "!%$", \_
                Optional ByRef P9 As Object = "!%$", Optional ByRef P10 As Object = "!%$", \_
                Optional ByRef P11 As Object = "!%$") As Object
    
            Dim Parms(0) As Object
    
            If P1.GetType Is GetType(String) Then If P1 = "!%$" Then GoTo a150
    
            Parms(0) = P1
    
            If P2.GetType Is GetType(String) Then If P2 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P2
            If P3.GetType Is GetType(String) Then If P3 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P3
            If P4.GetType Is GetType(String) Then If P4 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P4
            If P5.GetType Is GetType(String) Then If P5 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P5
            If P6.GetType Is GetType(String) Then If P6 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P6
            If P7.GetType Is GetType(String) Then If P7 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P7
            If P8.GetType Is GetType(String) Then If P8 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P8
            If P9.GetType Is GetType(String) Then If P9 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P9
            If P10.GetType Is GetType(String) Then If P10 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P10
            If P11.GetType Is GetType(String) Then If P11 = "!%$" Then GoTo a100
            ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P11
    

    a100:
    On Error GoTo a200

    K Offline
    K Offline
    Kyle Moyer
    wrote on last edited by
    #5

    Rob Grainger wrote:

    How many bad practices can y'all spot in this? .... (PS - this is actually VB.NET code).

    Kind of you to start the list for us. :-\

    R 1 Reply Last reply
    0
    • K Kyle Moyer

      Rob Grainger wrote:

      How many bad practices can y'all spot in this? .... (PS - this is actually VB.NET code).

      Kind of you to start the list for us. :-\

      R Offline
      R Offline
      Rob Grainger
      wrote on last edited by
      #6

      I had to highlight that - at a casual glance it looks just like VB6 code, which is a WTF in itself.

      "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

      S 1 Reply Last reply
      0
      • B Brisingr Aerowing

        WTF? Whoever wrote that needs to be strung up by his pinky fingers!

        What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

        R Offline
        R Offline
        Rob Grainger
        wrote on last edited by
        #7

        Sadly, its 3rd party code I have to interface to. It kinda works, but X| ! (At least it works 'til it fails horribly, when someone calls a function with one too many parameters, when it fail ungracefully)

        "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

        B 2 Replies Last reply
        0
        • S Simon_Whale

          I gave up counting them after reading optional byref p2 as object just luckily its the practically weekend at 5:30 today (long live the long weekend :D)

          Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

          R Offline
          R Offline
          Rob Grainger
          wrote on last edited by
          #8

          Luckily I've got two weeks vacation - I think I need it. My eyes are bleeding.

          "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

          1 Reply Last reply
          0
          • R Rob Grainger

            Sadly, its 3rd party code I have to interface to. It kinda works, but X| ! (At least it works 'til it fails horribly, when someone calls a function with one too many parameters, when it fail ungracefully)

            "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

            B Offline
            B Offline
            Brisingr Aerowing
            wrote on last edited by
            #9

            Have somea lot of :beer:.

            What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

            1 Reply Last reply
            0
            • R Rob Grainger

              Sadly, its 3rd party code I have to interface to. It kinda works, but X| ! (At least it works 'til it fails horribly, when someone calls a function with one too many parameters, when it fail ungracefully)

              "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

              B Offline
              B Offline
              Brisingr Aerowing
              wrote on last edited by
              #10

              Oh, and the person who created this needs to be bashed over the head with a solid iron clue bat. Several times.

              What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

              1 Reply Last reply
              0
              • R Rob Grainger

                I think this just speaks for itself... (I apologise in advance for the pain caused) How many bad practices can y'all spot in this?

                    Function InvokeMember(MethodName As String, \_
                            Optional ByRef P1 As Object = "!%$", Optional ByRef P2 As Object = "!%$", \_
                            Optional ByRef P3 As Object = "!%$", Optional ByRef P4 As Object = "!%$", \_
                            Optional ByRef P5 As Object = "!%$", Optional ByRef P6 As Object = "!%$", \_
                            Optional ByRef P7 As Object = "!%$", Optional ByRef P8 As Object = "!%$", \_
                            Optional ByRef P9 As Object = "!%$", Optional ByRef P10 As Object = "!%$", \_
                            Optional ByRef P11 As Object = "!%$") As Object
                
                        Dim Parms(0) As Object
                
                        If P1.GetType Is GetType(String) Then If P1 = "!%$" Then GoTo a150
                
                        Parms(0) = P1
                
                        If P2.GetType Is GetType(String) Then If P2 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P2
                        If P3.GetType Is GetType(String) Then If P3 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P3
                        If P4.GetType Is GetType(String) Then If P4 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P4
                        If P5.GetType Is GetType(String) Then If P5 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P5
                        If P6.GetType Is GetType(String) Then If P6 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P6
                        If P7.GetType Is GetType(String) Then If P7 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P7
                        If P8.GetType Is GetType(String) Then If P8 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P8
                        If P9.GetType Is GetType(String) Then If P9 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P9
                        If P10.GetType Is GetType(String) Then If P10 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P10
                        If P11.GetType Is GetType(String) Then If P11 = "!%$" Then GoTo a100
                        ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P11
                

                a100:
                On Error GoTo a200

                J Offline
                J Offline
                Jorgen Andersson
                wrote on last edited by
                #11

                But why would you want to do something like that? :confused:

                Wrong is evil and must be defeated. - Jeff Ello

                1 Reply Last reply
                0
                • R Rob Grainger

                  I think this just speaks for itself... (I apologise in advance for the pain caused) How many bad practices can y'all spot in this?

                      Function InvokeMember(MethodName As String, \_
                              Optional ByRef P1 As Object = "!%$", Optional ByRef P2 As Object = "!%$", \_
                              Optional ByRef P3 As Object = "!%$", Optional ByRef P4 As Object = "!%$", \_
                              Optional ByRef P5 As Object = "!%$", Optional ByRef P6 As Object = "!%$", \_
                              Optional ByRef P7 As Object = "!%$", Optional ByRef P8 As Object = "!%$", \_
                              Optional ByRef P9 As Object = "!%$", Optional ByRef P10 As Object = "!%$", \_
                              Optional ByRef P11 As Object = "!%$") As Object
                  
                          Dim Parms(0) As Object
                  
                          If P1.GetType Is GetType(String) Then If P1 = "!%$" Then GoTo a150
                  
                          Parms(0) = P1
                  
                          If P2.GetType Is GetType(String) Then If P2 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P2
                          If P3.GetType Is GetType(String) Then If P3 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P3
                          If P4.GetType Is GetType(String) Then If P4 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P4
                          If P5.GetType Is GetType(String) Then If P5 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P5
                          If P6.GetType Is GetType(String) Then If P6 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P6
                          If P7.GetType Is GetType(String) Then If P7 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P7
                          If P8.GetType Is GetType(String) Then If P8 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P8
                          If P9.GetType Is GetType(String) Then If P9 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P9
                          If P10.GetType Is GetType(String) Then If P10 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P10
                          If P11.GetType Is GetType(String) Then If P11 = "!%$" Then GoTo a100
                          ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P11
                  

                  a100:
                  On Error GoTo a200

                  Sander RosselS Offline
                  Sander RosselS Offline
                  Sander Rossel
                  wrote on last edited by
                  #12

                  Rob Grainger wrote:

                  (PS - this is actually VB.NET code).

                  It's a disgrace, and that's language agnostic (which is pretty hip by the way) :D

                  Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                  Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                  Regards, Sander

                  R 1 Reply Last reply
                  0
                  • Sander RosselS Sander Rossel

                    Rob Grainger wrote:

                    (PS - this is actually VB.NET code).

                    It's a disgrace, and that's language agnostic (which is pretty hip by the way) :D

                    Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                    Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                    Regards, Sander

                    R Offline
                    R Offline
                    Rob Grainger
                    wrote on last edited by
                    #13

                    Sander Rossel wrote:

                    It's a disgrace, and that's language agnostic (which is pretty hip by the way)

                    I'm trying real hard to take it to the next level and be language atheist, but its not working out to well so far. ;-)

                    "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                    Sander RosselS 1 Reply Last reply
                    0
                    • R Rob Grainger

                      Sander Rossel wrote:

                      It's a disgrace, and that's language agnostic (which is pretty hip by the way)

                      I'm trying real hard to take it to the next level and be language atheist, but its not working out to well so far. ;-)

                      "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #14

                      I love VB.NET and I love C#. I'm trying to love JavaScript, but it just gives me so much reasons to hate it... I really hate HTML and CSS and I'm past the points where I'd like to like it. They're not programming languages anyway. Each language you know makes learning another language easier. Try to look past the language specific part and see how your knowledge about some language can be applied to other languages :D

                      Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                      Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                      Regards, Sander

                      R 1 Reply Last reply
                      0
                      • Sander RosselS Sander Rossel

                        I love VB.NET and I love C#. I'm trying to love JavaScript, but it just gives me so much reasons to hate it... I really hate HTML and CSS and I'm past the points where I'd like to like it. They're not programming languages anyway. Each language you know makes learning another language easier. Try to look past the language specific part and see how your knowledge about some language can be applied to other languages :D

                        Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                        Regards, Sander

                        R Offline
                        R Offline
                        Rob Grainger
                        wrote on last edited by
                        #15

                        "Each language you know makes learning another language easier." Don't know, after a point if you keep learning similar (read imperative, OO) languages you reach a point where you pick up another one quickly, but you'll still have a certain time. Normally its libraries/frameworks which take most time. Especially for JavaScript where there seems to a new framework every day. To really push yourself step outside the comfort zone. Try a functional language (A LISP variant and Haskell are particular good for going outside the comfort zone). Try a real OO language like Smalltalk. That kind of difference changes the whole way you think about programming.

                        "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                        Sander RosselS 1 Reply Last reply
                        0
                        • R Rob Grainger

                          "Each language you know makes learning another language easier." Don't know, after a point if you keep learning similar (read imperative, OO) languages you reach a point where you pick up another one quickly, but you'll still have a certain time. Normally its libraries/frameworks which take most time. Especially for JavaScript where there seems to a new framework every day. To really push yourself step outside the comfort zone. Try a functional language (A LISP variant and Haskell are particular good for going outside the comfort zone). Try a real OO language like Smalltalk. That kind of difference changes the whole way you think about programming.

                          "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                          Sander RosselS Offline
                          Sander RosselS Offline
                          Sander Rossel
                          wrote on last edited by
                          #16

                          Even the JavaScript frameworks look similar after a while. Once you know what they do it's relatively easy to find how they do it. Usually there are some HTML bindings, some viewModel thingy, etc. I know C#, VB(.NET), SQL, JavaScript, HTML, CSS, LESS, some Haskell, F#, and Java, and I've read other languages like Lisp, Ada, C, C++, and Cobol. I should try a non-managed language some time, and I mean really working with it. Learning new languages can be fun, it's just a little useless if you can't really use it in day to day life :sigh: Although learning Haskell and F# did make me a better C# programmer.

                          Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

                          Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                          Regards, Sander

                          1 Reply Last reply
                          0
                          • R Rob Grainger

                            I think this just speaks for itself... (I apologise in advance for the pain caused) How many bad practices can y'all spot in this?

                                Function InvokeMember(MethodName As String, \_
                                        Optional ByRef P1 As Object = "!%$", Optional ByRef P2 As Object = "!%$", \_
                                        Optional ByRef P3 As Object = "!%$", Optional ByRef P4 As Object = "!%$", \_
                                        Optional ByRef P5 As Object = "!%$", Optional ByRef P6 As Object = "!%$", \_
                                        Optional ByRef P7 As Object = "!%$", Optional ByRef P8 As Object = "!%$", \_
                                        Optional ByRef P9 As Object = "!%$", Optional ByRef P10 As Object = "!%$", \_
                                        Optional ByRef P11 As Object = "!%$") As Object
                            
                                    Dim Parms(0) As Object
                            
                                    If P1.GetType Is GetType(String) Then If P1 = "!%$" Then GoTo a150
                            
                                    Parms(0) = P1
                            
                                    If P2.GetType Is GetType(String) Then If P2 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P2
                                    If P3.GetType Is GetType(String) Then If P3 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P3
                                    If P4.GetType Is GetType(String) Then If P4 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P4
                                    If P5.GetType Is GetType(String) Then If P5 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P5
                                    If P6.GetType Is GetType(String) Then If P6 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P6
                                    If P7.GetType Is GetType(String) Then If P7 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P7
                                    If P8.GetType Is GetType(String) Then If P8 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P8
                                    If P9.GetType Is GetType(String) Then If P9 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P9
                                    If P10.GetType Is GetType(String) Then If P10 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P10
                                    If P11.GetType Is GetType(String) Then If P11 = "!%$" Then GoTo a100
                                    ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P11
                            

                            a100:
                            On Error GoTo a200

                            J Offline
                            J Offline
                            Jalapeno Bob
                            wrote on last edited by
                            #17

                            Yuck! That reads like FORTRAN 66 was the author's first programming language. :laugh:

                            __________________ Lord, grant me the serenity to accept that there are some things I just can’t keep up with, the determination to keep up with the things I must keep up with, and the wisdom to find a good RSS feed from someone who keeps up with what I’d like to, but just don’t have the damn bandwidth to handle right now. © 2009, Rex Hammock

                            1 Reply Last reply
                            0
                            • R Rob Grainger

                              I had to highlight that - at a casual glance it looks just like VB6 code, which is a WTF in itself.

                              "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                              S Offline
                              S Offline
                              Sinisa Hajnal
                              wrote on last edited by
                              #18

                              I was just about to comment that is looks more as VB6 then VB.NET It is a terrible, terrible mess of VB6 programmer(s) trying to cross over :omg:

                              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