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. Everything That Has a Beginning Has an End (Eventually)

Everything That Has a Beginning Has an End (Eventually)

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasecsharplinqcom
23 Posts 11 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.
  • A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #1

    I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

    '''<Summary>
    '''The method returns the view for the index given.
    '''</Summary>
    Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
    If (index = 0) Then
    Return GetView0
    End If
    If (index = 1) Then
    Return GetView1
    End If
    If (index = 2) Then
    Return GetView2
    End If
    If (index = 3) Then
    Return GetView3
    End If
    If (index = 4) Then
    Return GetView4
    End If
    If (index = 5) Then
    Return GetView5
    End If
    ' ...lots and lots of lines...
    If (index = 1461) Then
    Return GetView1461
    End If
    If (index = 1462) Then
    Return GetView1462
    End If
    If (index = 1463) Then
    Return GetView1463
    End If
    Throw New System.IndexOutOfRangeException()
    End Function

    This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

    Driven to the ARMs by x86.

    B OriginalGriffO J S L 8 Replies Last reply
    0
    • A AspDotNetDev

      I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

      '''<Summary>
      '''The method returns the view for the index given.
      '''</Summary>
      Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
      If (index = 0) Then
      Return GetView0
      End If
      If (index = 1) Then
      Return GetView1
      End If
      If (index = 2) Then
      Return GetView2
      End If
      If (index = 3) Then
      Return GetView3
      End If
      If (index = 4) Then
      Return GetView4
      End If
      If (index = 5) Then
      Return GetView5
      End If
      ' ...lots and lots of lines...
      If (index = 1461) Then
      Return GetView1461
      End If
      If (index = 1462) Then
      Return GetView1462
      End If
      If (index = 1463) Then
      Return GetView1463
      End If
      Throw New System.IndexOutOfRangeException()
      End Function

      This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

      Driven to the ARMs by x86.

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      :omg:

      1 Reply Last reply
      0
      • A AspDotNetDev

        I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

        '''<Summary>
        '''The method returns the view for the index given.
        '''</Summary>
        Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
        If (index = 0) Then
        Return GetView0
        End If
        If (index = 1) Then
        Return GetView1
        End If
        If (index = 2) Then
        Return GetView2
        End If
        If (index = 3) Then
        Return GetView3
        End If
        If (index = 4) Then
        Return GetView4
        End If
        If (index = 5) Then
        Return GetView5
        End If
        ' ...lots and lots of lines...
        If (index = 1461) Then
        Return GetView1461
        End If
        If (index = 1462) Then
        Return GetView1462
        End If
        If (index = 1463) Then
        Return GetView1463
        End If
        Throw New System.IndexOutOfRangeException()
        End Function

        This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

        Driven to the ARMs by x86.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Noooo! Use a Select Case statement instead! :laugh:

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        J 1 Reply Last reply
        0
        • A AspDotNetDev

          I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

          '''<Summary>
          '''The method returns the view for the index given.
          '''</Summary>
          Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
          If (index = 0) Then
          Return GetView0
          End If
          If (index = 1) Then
          Return GetView1
          End If
          If (index = 2) Then
          Return GetView2
          End If
          If (index = 3) Then
          Return GetView3
          End If
          If (index = 4) Then
          Return GetView4
          End If
          If (index = 5) Then
          Return GetView5
          End If
          ' ...lots and lots of lines...
          If (index = 1461) Then
          Return GetView1461
          End If
          If (index = 1462) Then
          Return GetView1462
          End If
          If (index = 1463) Then
          Return GetView1463
          End If
          Throw New System.IndexOutOfRangeException()
          End Function

          This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

          Driven to the ARMs by x86.

          J Offline
          J Offline
          JonasSSH
          wrote on last edited by
          #4

          AspDotNetDev wrote:

          3 lines of reflection code

          do you mind explaining how? im novice at reflection :)

          A 1 Reply Last reply
          0
          • A AspDotNetDev

            I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

            '''<Summary>
            '''The method returns the view for the index given.
            '''</Summary>
            Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
            If (index = 0) Then
            Return GetView0
            End If
            If (index = 1) Then
            Return GetView1
            End If
            If (index = 2) Then
            Return GetView2
            End If
            If (index = 3) Then
            Return GetView3
            End If
            If (index = 4) Then
            Return GetView4
            End If
            If (index = 5) Then
            Return GetView5
            End If
            ' ...lots and lots of lines...
            If (index = 1461) Then
            Return GetView1461
            End If
            If (index = 1462) Then
            Return GetView1462
            End If
            If (index = 1463) Then
            Return GetView1463
            End If
            Throw New System.IndexOutOfRangeException()
            End Function

            This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

            Driven to the ARMs by x86.

            S Offline
            S Offline
            StM0n
            wrote on last edited by
            #5

            The machines are taking over... even stupidity isn't save...

            (yes|no|maybe)*

            1 Reply Last reply
            0
            • J JonasSSH

              AspDotNetDev wrote:

              3 lines of reflection code

              do you mind explaining how? im novice at reflection :)

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

              See my alternate tip/trick here. That uses reflection to get all properties of a certain type and then sets their values. Using reflection, you can also invoke a method using a string that is the name of the method. I'll leave that as an exercise for the reader.

              Driven to the ARMs by x86.

              1 Reply Last reply
              0
              • A AspDotNetDev

                I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

                '''<Summary>
                '''The method returns the view for the index given.
                '''</Summary>
                Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
                If (index = 0) Then
                Return GetView0
                End If
                If (index = 1) Then
                Return GetView1
                End If
                If (index = 2) Then
                Return GetView2
                End If
                If (index = 3) Then
                Return GetView3
                End If
                If (index = 4) Then
                Return GetView4
                End If
                If (index = 5) Then
                Return GetView5
                End If
                ' ...lots and lots of lines...
                If (index = 1461) Then
                Return GetView1461
                End If
                If (index = 1462) Then
                Return GetView1462
                End If
                If (index = 1463) Then
                Return GetView1463
                End If
                Throw New System.IndexOutOfRangeException()
                End Function

                This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

                Driven to the ARMs by x86.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Okay, which would you rather tell your boss at the end of the day: 1: I wrote 3 lines of code. 2: I used a code generator to write 5,000 lines of code for me - saved me 2 full days of work. I'm mean hey, it's your career but if you keep going for efficiency over productivity you'll be selling hotdogs on a street corner before long. The difference is that of actual value vs. perceived value - one will get you a raise and the other will turn you into a grumpy old man who has an office in the basement next to the dumpster.

                B 1 Reply Last reply
                0
                • L Lost User

                  Okay, which would you rather tell your boss at the end of the day: 1: I wrote 3 lines of code. 2: I used a code generator to write 5,000 lines of code for me - saved me 2 full days of work. I'm mean hey, it's your career but if you keep going for efficiency over productivity you'll be selling hotdogs on a street corner before long. The difference is that of actual value vs. perceived value - one will get you a raise and the other will turn you into a grumpy old man who has an office in the basement next to the dumpster.

                  B Offline
                  B Offline
                  BobJanova
                  wrote on last edited by
                  #8

                  1a: I wrote 3 lines of code instead of 5000, saving me 2 days of work and making the application more efficient. If your manager truly values auto-generated code volume then getting 'moved on' for writing better code is probably no bad thing, and I'm sure he'd be able to get a job at a better place than that.

                  L 1 Reply Last reply
                  0
                  • A AspDotNetDev

                    I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

                    '''<Summary>
                    '''The method returns the view for the index given.
                    '''</Summary>
                    Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
                    If (index = 0) Then
                    Return GetView0
                    End If
                    If (index = 1) Then
                    Return GetView1
                    End If
                    If (index = 2) Then
                    Return GetView2
                    End If
                    If (index = 3) Then
                    Return GetView3
                    End If
                    If (index = 4) Then
                    Return GetView4
                    End If
                    If (index = 5) Then
                    Return GetView5
                    End If
                    ' ...lots and lots of lines...
                    If (index = 1461) Then
                    Return GetView1461
                    End If
                    If (index = 1462) Then
                    Return GetView1462
                    End If
                    If (index = 1463) Then
                    Return GetView1463
                    End If
                    Throw New System.IndexOutOfRangeException()
                    End Function

                    This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

                    Driven to the ARMs by x86.

                    F Offline
                    F Offline
                    Fabio Franco
                    wrote on last edited by
                    #9

                    That's why I've always hated wizards: You never know the kind of magic they can produce! :doh:

                    C 1 Reply Last reply
                    0
                    • A AspDotNetDev

                      I just installed Linqer to convert some SQL to LINQ. Unfortunately, it bombed out on me, but not before automatically generating this code:

                      '''<Summary>
                      '''The method returns the view for the index given.
                      '''</Summary>
                      Protected Overrides Function GetViewAt(ByVal index As Integer) As System.Collections.Generic.KeyValuePair(Of String, String)
                      If (index = 0) Then
                      Return GetView0
                      End If
                      If (index = 1) Then
                      Return GetView1
                      End If
                      If (index = 2) Then
                      Return GetView2
                      End If
                      If (index = 3) Then
                      Return GetView3
                      End If
                      If (index = 4) Then
                      Return GetView4
                      End If
                      If (index = 5) Then
                      Return GetView5
                      End If
                      ' ...lots and lots of lines...
                      If (index = 1461) Then
                      Return GetView1461
                      End If
                      If (index = 1462) Then
                      Return GetView1462
                      End If
                      If (index = 1463) Then
                      Return GetView1463
                      End If
                      Throw New System.IndexOutOfRangeException()
                      End Function

                      This is about as bad as my 558 lines of QuickBasic glory. :(( This is probably one of those instances where 3 lines of reflection code is better than 5,000 lines of auto-generated code.

                      Driven to the ARMs by x86.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      I love how one branch of Microsoft evangelists preach accessors for every single class property (which I actually like), and the other one, preaches the most inflexible total hard binding of everything to the database schema :) With the big advantage of automatically generating the joins :)

                      1 Reply Last reply
                      0
                      • B BobJanova

                        1a: I wrote 3 lines of code instead of 5000, saving me 2 days of work and making the application more efficient. If your manager truly values auto-generated code volume then getting 'moved on' for writing better code is probably no bad thing, and I'm sure he'd be able to get a job at a better place than that.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        Yeah, my post was serious. :rolleyes: My entire career is based upon using code generation tools to enhance perceived value. My last performance evaluation: Boss: So, how many lines of code did you create this year? Me: Four million, thanks to the power of code generators. Boss: Wow, high productivity and automation combined. You get a 20% raise. Instead of using obvious jokes as a launching pad for grinding axes against code generation and bad management why don't you create your own rant thread. This is the perfect place to do it. Sheesh.

                        B 1 Reply Last reply
                        0
                        • L Lost User

                          Yeah, my post was serious. :rolleyes: My entire career is based upon using code generation tools to enhance perceived value. My last performance evaluation: Boss: So, how many lines of code did you create this year? Me: Four million, thanks to the power of code generators. Boss: Wow, high productivity and automation combined. You get a 20% raise. Instead of using obvious jokes as a launching pad for grinding axes against code generation and bad management why don't you create your own rant thread. This is the perfect place to do it. Sheesh.

                          B Offline
                          B Offline
                          BobJanova
                          wrote on last edited by
                          #12

                          Apologies, didn't get that it was a joke. It is too believable :( (My management is not like that, or I wouldn't be working here ;).)

                          L 1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            Noooo! Use a Select Case statement instead! :laugh:

                            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                            J Offline
                            J Offline
                            Jonathan C Dickinson
                            wrote on last edited by
                            #13

                            CodeDOM doesn't support switch; and I have seen the C# equivalent of that out and about.

                            He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chineese Proverb] Jonathan C Dickinson (C# Software Engineer)

                            1 Reply Last reply
                            0
                            • F Fabio Franco

                              That's why I've always hated wizards: You never know the kind of magic they can produce! :doh:

                              C Offline
                              C Offline
                              cpkilekofp
                              wrote on last edited by
                              #14

                              Fabio Franco wrote:

                              That's why I've always hated wizards: You never know the kind of magic they can produce! :doh:

                              They've been complaining about that ever since the first "wizards" (compilers, in this case) began generating assembly code from more readable "high-level language" code...sometimes with good reason :-D

                              A F 2 Replies Last reply
                              0
                              • B BobJanova

                                Apologies, didn't get that it was a joke. It is too believable :( (My management is not like that, or I wouldn't be working here ;).)

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #15

                                Well, no problem. I've a short fuse today. :D

                                1 Reply Last reply
                                0
                                • C cpkilekofp

                                  Fabio Franco wrote:

                                  That's why I've always hated wizards: You never know the kind of magic they can produce! :doh:

                                  They've been complaining about that ever since the first "wizards" (compilers, in this case) began generating assembly code from more readable "high-level language" code...sometimes with good reason :-D

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

                                  You used compilers that generated assembly code?

                                  Driven to the ARMs by x86.

                                  C 1 Reply Last reply
                                  0
                                  • A AspDotNetDev

                                    You used compilers that generated assembly code?

                                    Driven to the ARMs by x86.

                                    C Offline
                                    C Offline
                                    cpkilekofp
                                    wrote on last edited by
                                    #17

                                    AspDotNetDev wrote:

                                    You used compilers that generated assembly code?

                                    LMAO, I may be missing the joke here, but yes, I did...I remember articles about MS 5.0 C's code generation vs. Borland's (now Symantec's?) Turbo C 6.0, arguing about code density vs. efficiency across memory architectures which might one day exceed sixteen bits available for data on the average person's desktop, especially with the expanding presence of the 32-bit 80386 processor in the business workplace...yes, those days. I actually entered a program in machine code into Debug which, after I saved it as reboot.com, dutifully rebooted the system every time I ran it. Bare-metal stuff, indeed...though I never got that (expletives deleted) COM port driver to work. But then, these intermediate languages in use now often operate in environments where sequences of bytecodes can be compiled directly into the native machine code of the executing processor, so at that point we can either request a listing (if available) or use a procesor-specific disassembler (if, ahem, our license permits) to determine whether this Just-In-Time code is actually as efficient as it can be for that processsor. Or so I assume; I'm less ambitious these days about bare-metal efficiency, I just hope it's better than running the bytecode through the interpreter and leave it at that.

                                    A 1 Reply Last reply
                                    0
                                    • C cpkilekofp

                                      AspDotNetDev wrote:

                                      You used compilers that generated assembly code?

                                      LMAO, I may be missing the joke here, but yes, I did...I remember articles about MS 5.0 C's code generation vs. Borland's (now Symantec's?) Turbo C 6.0, arguing about code density vs. efficiency across memory architectures which might one day exceed sixteen bits available for data on the average person's desktop, especially with the expanding presence of the 32-bit 80386 processor in the business workplace...yes, those days. I actually entered a program in machine code into Debug which, after I saved it as reboot.com, dutifully rebooted the system every time I ran it. Bare-metal stuff, indeed...though I never got that (expletives deleted) COM port driver to work. But then, these intermediate languages in use now often operate in environments where sequences of bytecodes can be compiled directly into the native machine code of the executing processor, so at that point we can either request a listing (if available) or use a procesor-specific disassembler (if, ahem, our license permits) to determine whether this Just-In-Time code is actually as efficient as it can be for that processsor. Or so I assume; I'm less ambitious these days about bare-metal efficiency, I just hope it's better than running the bytecode through the interpreter and leave it at that.

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

                                      I thought perhaps you meant that the compiler generated machine code, but maybe you actually did use a compiler that generated assembly code. :)

                                      Driven to the ARMs by x86.

                                      C 1 Reply Last reply
                                      0
                                      • A AspDotNetDev

                                        I thought perhaps you meant that the compiler generated machine code, but maybe you actually did use a compiler that generated assembly code. :)

                                        Driven to the ARMs by x86.

                                        C Offline
                                        C Offline
                                        cpkilekofp
                                        wrote on last edited by
                                        #19

                                        :wtf: ...hmmm, time to up my daily dose of gingko biloba... :laugh:

                                        1 Reply Last reply
                                        0
                                        • C cpkilekofp

                                          Fabio Franco wrote:

                                          That's why I've always hated wizards: You never know the kind of magic they can produce! :doh:

                                          They've been complaining about that ever since the first "wizards" (compilers, in this case) began generating assembly code from more readable "high-level language" code...sometimes with good reason :-D

                                          F Offline
                                          F Offline
                                          Fabio Franco
                                          wrote on last edited by
                                          #20

                                          cpkilekofp wrote:

                                          They've been complaining about that ever since the first "wizards" (compilers, in this case) began generating assembly code from more readable "high-level language" code

                                          I surely hope our wizards today don't become the compilers of tomorrow, then I'll have to hang myself. X|

                                          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