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

    I Offline
    I Offline
    icestatue
    wrote on last edited by
    #21

    I was exposed to a similar situation but it didn't involve an auto generated tool so much as a terrible programmer. We had a stored procedure that used 13 parameters to be used as filters for a set of data that we would return to the users. After getting a complaint that the filter was acting strange I was told to review the procedure to find the bug. When I opened the procedure I noticed that an if then else chain of about 3000 combinations of variations of the select statement had been hand written to account for every scenario that could exist. The only problem was that we figured that this was only a small fraction of the coverage of code needed to work correctly we also noticed when coping the procedure it was more the 5 megs in length. We were able to shorten the script to about 12 lines of code when we finished it.

    nothing

    A L 2 Replies Last reply
    0
    • I icestatue

      I was exposed to a similar situation but it didn't involve an auto generated tool so much as a terrible programmer. We had a stored procedure that used 13 parameters to be used as filters for a set of data that we would return to the users. After getting a complaint that the filter was acting strange I was told to review the procedure to find the bug. When I opened the procedure I noticed that an if then else chain of about 3000 combinations of variations of the select statement had been hand written to account for every scenario that could exist. The only problem was that we figured that this was only a small fraction of the coverage of code needed to work correctly we also noticed when coping the procedure it was more the 5 megs in length. We were able to shorten the script to about 12 lines of code when we finished it.

      nothing

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

      :laugh: I've seen some long stored procedures in my day. Perhaps 100 or 200K. But nothing like what you describe. Though, there was one grouped stored procedure that was composed of a hundred or so individual stored procedures (e.g., procedure;1, procedure;2, procedure;100, procedure;101, and so on). Still, that was due to decades of hopelessly complicated business logic and workarounds, not one very simple but bloated function, like the one you described.

      Driven to the ARMs by x86.

      1 Reply Last reply
      0
      • I icestatue

        I was exposed to a similar situation but it didn't involve an auto generated tool so much as a terrible programmer. We had a stored procedure that used 13 parameters to be used as filters for a set of data that we would return to the users. After getting a complaint that the filter was acting strange I was told to review the procedure to find the bug. When I opened the procedure I noticed that an if then else chain of about 3000 combinations of variations of the select statement had been hand written to account for every scenario that could exist. The only problem was that we figured that this was only a small fraction of the coverage of code needed to work correctly we also noticed when coping the procedure it was more the 5 megs in length. We were able to shorten the script to about 12 lines of code when we finished it.

        nothing

        L Offline
        L Offline
        Lutoslaw
        wrote on last edited by
        #23

        icestatue wrote:

        We were able to shorten the script to about 12 lines of code when we finished it.

        :doh: How long these lines were?

        Greetings - Jacek

        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