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. The Lounge
  3. My friend has written a function 831 lines long.

My friend has written a function 831 lines long.

Scheduled Pinned Locked Moved The Lounge
question
43 Posts 25 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.
  • H Hoornet93

    In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #4

    I've got a couple methods that are more than 500 lines long, therefore, I ask "So?" and as an argument, to consider that if it's commented, nicely formatted, and it makes sense, then there shouldn't be any problems with the code, as examplified by a common requirement that I have, in which I write a lot of analysis routines where performance is THE issue and the performance hit of a function call is unacceptable (and the compiler won't inline it), which results in very long functions. And run-on sentences. Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

    N 1 Reply Last reply
    0
    • H Hoornet93

      In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

      G Offline
      G Offline
      Gavin Greig
      wrote on last edited by
      #5

      Hoornet@Job wrote: Do u know a longer function? I wish I could say no... Our longest method at the moment appears to contain 439 statements, but that's only because we've managed to get rid of some of the real monsters! Gavin Greig "Haw, you're no deid," girned Charon. "Get aff ma boat or ah'll report ye." Matthew Fitt - The Hoose O Haivers: The Twelve Trauchles O Heracles.

      1 Reply Last reply
      0
      • S Shaun Wilde

        Hoornet@Job wrote: Do u know a longer function? no but I bet when you find it its written in VB

        Stupidity dies. The end of future offspring. Evolution wins. - A Darwin Awards Haiku

        N Offline
        N Offline
        Navin
        wrote on last edited by
        #6

        Actually, I found one that was at least a thousand lines long. It was written in VC++, but it was really just FORTRAN code "ported" over. (To be fair, eventually that whole design was re-worked, and the function that took its place was less than 100 lines long. :-D ) Even a broken clock is right twice a day.

        1 Reply Last reply
        0
        • M Marc Clifton

          I've got a couple methods that are more than 500 lines long, therefore, I ask "So?" and as an argument, to consider that if it's commented, nicely formatted, and it makes sense, then there shouldn't be any problems with the code, as examplified by a common requirement that I have, in which I write a lot of analysis routines where performance is THE issue and the performance hit of a function call is unacceptable (and the compiler won't inline it), which results in very long functions. And run-on sentences. Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

          N Offline
          N Offline
          Navin
          wrote on last edited by
          #7

          Just buy a faster machine. :-D Even a broken clock is right twice a day.

          W 1 Reply Last reply
          0
          • P Paul Watson

            Hoornet@Job wrote: Do u know a longer function? A contracter did an ASP page for us once. It had to Add, Edit and Delete some records. He put everything into one page and repeated all the HTML for each function. The page is 5423 lines long. When I press page down in VS.NET it takes 5 seconds before the screen updates! Suffice to say we deleted the page and re-did it, because trying to edit that monster would have taken longer.

            Paul Watson
            Bluegrass
            Cape Town, South Africa

            Colin Davies wrote: ...can you imagine a John Simmons stalker !

            J Offline
            J Offline
            Jason Gerard
            wrote on last edited by
            #8

            I worked with someone that did that. The page was at least 5000 lines. I also worked with someone that used multiple connection objects in an ASP page to run multiple queries. A new connection for every query, and there were quite a few queries. It was all connecting to the same database. Quite sad actually. Jason Gerard "This almost never matters, except quite often."

            D Richard DeemingR 2 Replies Last reply
            0
            • N Navin

              Just buy a faster machine. :-D Even a broken clock is right twice a day.

              W Offline
              W Offline
              Wouter Dhondt
              wrote on last edited by
              #9

              Navin wrote: Just buy a faster machine. Ah yes, the perfect solution. I'm going to tell my client to buy 2500 new machines so they can run my poorly written code ;P ... Performance in code is still important, even with the machines we have today. Don't want to end up as a VB "programmer" that writes poor code... ----------------------- New and improved: kwakkelflap.com My first CP article: Pseudoregisters[^] "When I hear of Schrödinger's cat, I reach for my gun." - Stephen Hawking

              1 Reply Last reply
              0
              • H Hoornet93

                In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

                P Offline
                P Offline
                Pete Bassett
                wrote on last edited by
                #10

                Sorry guys, but I've got you all beat. I only heard about this after the fact but a colleague of mine in another department was given the task of writting a function which, given one "name" would return a shorter equivalent. Weeks later he emerged triumphant and presented the world with a VB function which consisted of one long Select statement. I dont know how many lines long the function was, but we printed it out onto A4 sheets. It took over half an hour and the stack was 2 inches thick. Now thats a function! Needless to say, someone wrote a 5 line equivalent that just did a look up in an Access table. Pete


                Insert Sig. Here!

                M N 2 Replies Last reply
                0
                • H Hoornet93

                  In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

                  S Offline
                  S Offline
                  SimonS
                  wrote on last edited by
                  #11

                  Sure. I've just finished consulting at a large company that has a VB class over 10,000 lines long and with some functions well over 1500 lines long. How's them apples? Cheers, Simon "From now on, if rogue states want to buy weapons of mass destruction, they're going to have to go on eBay," Mr. Bezos said.

                  1 Reply Last reply
                  0
                  • H Hoornet93

                    In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

                    W Offline
                    W Offline
                    Wouter Dhondt
                    wrote on last edited by
                    #12

                    Longest I've seen: around 7400 lines. It's a c++ function to parse a string using a state machine / huge switch (with other switches in the cases). ----------------------- New and improved: kwakkelflap.com My first CP article: Pseudoregisters[^] "When I hear of Schrödinger's cat, I reach for my gun." - Stephen Hawking

                    S D 2 Replies Last reply
                    0
                    • W Wouter Dhondt

                      Longest I've seen: around 7400 lines. It's a c++ function to parse a string using a state machine / huge switch (with other switches in the cases). ----------------------- New and improved: kwakkelflap.com My first CP article: Pseudoregisters[^] "When I hear of Schrödinger's cat, I reach for my gun." - Stephen Hawking

                      S Offline
                      S Offline
                      Simon Walton
                      wrote on last edited by
                      #13

                      Kwakkie wrote: around 7400 lines :wtf:

                      Simon Walton
                      Sonork: 10024

                      P

                      1 Reply Last reply
                      0
                      • J Jason Gerard

                        I worked with someone that did that. The page was at least 5000 lines. I also worked with someone that used multiple connection objects in an ASP page to run multiple queries. A new connection for every query, and there were quite a few queries. It was all connecting to the same database. Quite sad actually. Jason Gerard "This almost never matters, except quite often."

                        D Offline
                        D Offline
                        Daniel Turini
                        wrote on last edited by
                        #14

                        Jason Gerard wrote: I also worked with someone that used multiple connection objects in an ASP page to run multiple queries. A new connection for every query, and there were quite a few queries. It was all connecting to the same database. Quite sad actually. If he closed the connection right after using it, sorry to say, but he was right. The IIS will manage a ADO connection pool and "closing" a connection returns it more quickly to the pool. My latest article: SQL Server DO's and DONT's[^]

                        J P 2 Replies Last reply
                        0
                        • H Hoornet93

                          In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

                          S Offline
                          S Offline
                          Steve Hopkins
                          wrote on last edited by
                          #15

                          We have a bought in third party control, functions regulary reach 3k lines. But a trainer came in one time, and scared us senseless with a story of a function witten at HP which was 20k lines long. :wtf: if(E_NOINTERFACE == pThat->QueryInterface(IID_IUnknown,(void**)&pUnk)) { // I aint no pUnk bitch! }

                          1 Reply Last reply
                          0
                          • W Wouter Dhondt

                            Longest I've seen: around 7400 lines. It's a c++ function to parse a string using a state machine / huge switch (with other switches in the cases). ----------------------- New and improved: kwakkelflap.com My first CP article: Pseudoregisters[^] "When I hear of Schrödinger's cat, I reach for my gun." - Stephen Hawking

                            D Offline
                            D Offline
                            Daniel Turini
                            wrote on last edited by
                            #16

                            Nah, code generated by YACC doesn't count :) My latest article: SQL Server DO's and DONT's[^]

                            W 1 Reply Last reply
                            0
                            • H Hoornet93

                              In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! Do u know a longer function? Love is the law, love under will.

                              D Offline
                              D Offline
                              Daniel Turini
                              wrote on last edited by
                              #17

                              Hoornet@Job wrote: In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! The worst kind of code is when you see a big function calling several other fellow big functions :) My latest article: SQL Server DO's and DONT's[^]

                              T 1 Reply Last reply
                              0
                              • D Daniel Turini

                                Nah, code generated by YACC doesn't count :) My latest article: SQL Server DO's and DONT's[^]

                                W Offline
                                W Offline
                                Wouter Dhondt
                                wrote on last edited by
                                #18

                                LOL. Well, it isn't. Count exactly: 7428 lines... (and growing). How on earth can you get 7400 lines function of YACC generated code. Our generated code is split up nicely in different functions (although we have big tables of course). Won't try to read it though... ----------------------- New and improved: kwakkelflap.com My first CP article: Pseudoregisters[^] "When I hear of Schrödinger's cat, I reach for my gun." - Stephen Hawking

                                1 Reply Last reply
                                0
                                • D Daniel Turini

                                  Hoornet@Job wrote: In my company i got the task to modify something in my friend Visual C code. Imagine my surprise when I saw a function 831 linel long!!! The worst kind of code is when you see a big function calling several other fellow big functions :) My latest article: SQL Server DO's and DONT's[^]

                                  T Offline
                                  T Offline
                                  Tim Smith
                                  wrote on last edited by
                                  #19

                                  The worst kind of code is when you see a big function calling several other fellow big functions Where most arguments are passed via global variables. :) Tim Smith I'm going to patent thought. I have yet to see any prior art.

                                  1 Reply Last reply
                                  0
                                  • D Daniel Turini

                                    Jason Gerard wrote: I also worked with someone that used multiple connection objects in an ASP page to run multiple queries. A new connection for every query, and there were quite a few queries. It was all connecting to the same database. Quite sad actually. If he closed the connection right after using it, sorry to say, but he was right. The IIS will manage a ADO connection pool and "closing" a connection returns it more quickly to the pool. My latest article: SQL Server DO's and DONT's[^]

                                    J Offline
                                    J Offline
                                    Jason Gerard
                                    wrote on last edited by
                                    #20

                                    Well, I don't recall everything about the page, this was about 2 years ago. I know I trashed it and rewrote it with just one object and it went from taking 30+ seconds to load to just under 1-3 seconds. Jason Gerard "This almost never matters, except quite often."

                                    1 Reply Last reply
                                    0
                                    • P Pete Bassett

                                      Sorry guys, but I've got you all beat. I only heard about this after the fact but a colleague of mine in another department was given the task of writting a function which, given one "name" would return a shorter equivalent. Weeks later he emerged triumphant and presented the world with a VB function which consisted of one long Select statement. I dont know how many lines long the function was, but we printed it out onto A4 sheets. It took over half an hour and the stack was 2 inches thick. Now thats a function! Needless to say, someone wrote a 5 line equivalent that just did a look up in an Access table. Pete


                                      Insert Sig. Here!

                                      M Offline
                                      M Offline
                                      Marc Clifton
                                      wrote on last edited by
                                      #21

                                      And the amazing thing is that the database server actually accepted and parsed it???? :omg: Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

                                      P 1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        And the amazing thing is that the database server actually accepted and parsed it???? :omg: Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

                                        P Offline
                                        P Offline
                                        Pete Bassett
                                        wrote on last edited by
                                        #22

                                        Marc Clifton wrote: the database server actually accepted and parsed it ? If you're asking how we generated the Access table, its pretty easy to write a parser for such a small set of language. Case "Peter" GetShortName = "Pete" Case "Joeseph" GetShortName = "Joe" Then just put the "Case" token in the LongName column and the "GetShortName" token in the ShortName column. Horrible! Oh, it just makes me cringe every time I think of it...Uuuugggghghhh... Pete


                                        Insert Sig. Here!

                                        M 1 Reply Last reply
                                        0
                                        • P Paul Watson

                                          Hoornet@Job wrote: Do u know a longer function? A contracter did an ASP page for us once. It had to Add, Edit and Delete some records. He put everything into one page and repeated all the HTML for each function. The page is 5423 lines long. When I press page down in VS.NET it takes 5 seconds before the screen updates! Suffice to say we deleted the page and re-did it, because trying to edit that monster would have taken longer.

                                          Paul Watson
                                          Bluegrass
                                          Cape Town, South Africa

                                          Colin Davies wrote: ...can you imagine a John Simmons stalker !

                                          realJSOPR Offline
                                          realJSOPR Offline
                                          realJSOP
                                          wrote on last edited by
                                          #23

                                          No, he's talking about program code. Writing HTML pages is NOT programming. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                                          P 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