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.
  • 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
            • 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[^]

              P Offline
              P Offline
              Paul Watson
              wrote on last edited by
              #24

              Daniel Turini wrote: 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. I think Jason meant there was a connection object for each query, not one re-used connection object. e.g.

              set oconn1 = server.create....
              set rs1 = server.create...

              set oconn2 = server.create....
              set rs2 = server.create...

              set oconn3 = server.create....
              set rs3 = server.create...

              That surely cannot be right.

              Paul Watson
              Bluegrass
              Cape Town, South Africa

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

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

                C Offline
                C Offline
                Chris Meech
                wrote on last edited by
                #25

                Not only have I come across functions with a greater number of lines, how's about what the functions were to do! I took over a DB reporting app that had a CView derived class that generated SQL on the fly, queried the database, built a huge array of strings to hold all the data. Only problem was it did this all in the OnDraw() method. Guess what happened whenever you tried to scroll the window? :) Or printed a report. Chris Meech "what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002. "AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.

                N 1 Reply Last reply
                0
                • realJSOPR realJSOP

                  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 Offline
                  P Offline
                  Paul Watson
                  wrote on last edited by
                  #26

                  John Simmons / outlaw programmer wrote: No, he's talking about program code. Writing HTML pages is NOT programming. "the staggering layers of originality in your statement make it a work of art on so many levels" Come on John, you can do better than that!

                  Paul Watson
                  Bluegrass
                  Cape Town, South Africa

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

                  1 Reply Last reply
                  0
                  • P Paul Watson

                    Daniel Turini wrote: 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. I think Jason meant there was a connection object for each query, not one re-used connection object. e.g.

                    set oconn1 = server.create....
                    set rs1 = server.create...

                    set oconn2 = server.create....
                    set rs2 = server.create...

                    set oconn3 = server.create....
                    set rs3 = server.create...

                    That surely cannot be right.

                    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
                    #27

                    Paul Watson wrote: think Jason meant there was a connection object for each query, not one re-used connection object. Exactly. Jason Gerard "This almost never matters, except quite often."

                    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.

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #28

                      sure. i have a couple that are easily over 1100 lines. -c


                      A conclusion is simply the place where someone got tired of thinking.

                      Smaller Animals Software

                      N 1 Reply Last reply
                      0
                      • P Pete Bassett

                        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 Offline
                        M Offline
                        Marc Clifton
                        wrote on last edited by
                        #29

                        No, I meant that the server actually processed the 2 inch stack of A4 paper representing the SELECT statement. Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

                        P 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
                          William E Kempf
                          wrote on last edited by
                          #30

                          No, but I've got another one for people to try and top. Someone in our company once wrote a Windows control (strictly C API) to do formatted editing (things like date entry, currency entry, etc.). I was tasked with fixing a bug in the control, so I fired 4Print (a utility that prints multiple pages on a single page), opened the single source file, and hit print (with complex code, I often find it easier to read hard copy, where I can mark up the code with notes). After a few minutes had passed and I'd not received a notification that the print job was done, I looked in the print spool to see what was going on. I was shocked to see that the print job was over 500 pages long! Since this was 4Printed, that means it was actually over 1000 pages of code! :eek: Needless to say, instead of fixing the bug I just wrote a new control from scratch. Retained all the functionality in under 25 pages of code. Made me wonder if the developer was getting paid by the LOC. William E. Kempf

                          1 Reply Last reply
                          0
                          • M Marc Clifton

                            No, I meant that the server actually processed the 2 inch stack of A4 paper representing the SELECT statement. 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
                            #31

                            Ah, now I see the consusion. No, it wasn't a SQL Select. it was a VB one E.g.

                            Public Function GetShortName(strName as String) as String
                            Select Case strName
                            ...
                            Case "Peter"
                            GetShortName = "Pete"
                            Case "Joeseph"
                            GetShortName = "Joe"
                            Case "LongName"
                            GetShortName = "ShortName"
                            ...
                            End Select
                            End Function

                            And so on and so forth. Apparently I took quite a while to compile. Pete


                            Insert Sig. Here!

                            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.

                              N Offline
                              N Offline
                              Nemanja Trifunovic
                              wrote on last edited by
                              #32

                              Hoornet@Job wrote: Imagine my surprise when I saw a function 831 linel long!!! Only 831 lines? An amateur. :beer:

                              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.

                                N Offline
                                N Offline
                                Nick Parker
                                wrote on last edited by
                                #33

                                Hoornet@Job wrote: Do u know a longer function? I actually have a nice* stored procedure that does a huge compare process against two data sets in SQL Server that is at exactly 1311 lines long. I made sure I left a comment at the top something like this:

                                /*=================================================================
                                XXXXXXXXXXXXXXXXXXXXX
                                XXX -- WARNING -- XXX

                                                 Do NOT modify this procedure unless 
                                                 you absolutely know what you are doing.
                                

                                ==================================================================*/

                                *nice - otherwise known as a pain in the butt to write. Nick Parker
                                May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                                P 1 Reply Last reply
                                0
                                • C Chris Meech

                                  Not only have I come across functions with a greater number of lines, how's about what the functions were to do! I took over a DB reporting app that had a CView derived class that generated SQL on the fly, queried the database, built a huge array of strings to hold all the data. Only problem was it did this all in the OnDraw() method. Guess what happened whenever you tried to scroll the window? :) Or printed a report. Chris Meech "what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002. "AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.

                                  N Offline
                                  N Offline
                                  Nick Parker
                                  wrote on last edited by
                                  #34

                                  Chris Meech wrote: Guess what happened whenever you tried to scroll the window? Or printed a report. Absolutely hilarious. :laugh: Nick Parker
                                  May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                                  1 Reply Last reply
                                  0
                                  • P Paul Watson

                                    Daniel Turini wrote: 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. I think Jason meant there was a connection object for each query, not one re-used connection object. e.g.

                                    set oconn1 = server.create....
                                    set rs1 = server.create...

                                    set oconn2 = server.create....
                                    set rs2 = server.create...

                                    set oconn3 = server.create....
                                    set rs3 = server.create...

                                    That surely cannot be right.

                                    Paul Watson
                                    Bluegrass
                                    Cape Town, South Africa

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

                                    N Offline
                                    N Offline
                                    Nick Parker
                                    wrote on last edited by
                                    #35

                                    Paul Watson wrote: That surely cannot be right. Don't doubt yourself mate. ;) Nick Parker
                                    May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                                    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!

                                      N Offline
                                      N Offline
                                      Nick Parker
                                      wrote on last edited by
                                      #36

                                      Pete Bassett wrote: Weeks later he emerged triumphant and presented the world with a VB function Quick, I think I see the problem.... ;P Nick Parker
                                      May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                                      1 Reply Last reply
                                      0
                                      • C Chris Losinger

                                        sure. i have a couple that are easily over 1100 lines. -c


                                        A conclusion is simply the place where someone got tired of thinking.

                                        Smaller Animals Software

                                        N Offline
                                        N Offline
                                        Nick Parker
                                        wrote on last edited by
                                        #37

                                        Chris Losinger wrote: i have a couple that are easily over 1100 lines. How would that look in C#, just kidding with you Chris... Nick Parker
                                        May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                                        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.

                                          T Offline
                                          T Offline
                                          Thomas Freudenberg
                                          wrote on last edited by
                                          #38

                                          One guy in our company has written a function 5317 lines long :omg: Not that maintainable... Regards Thomas Sonork id: 100.10453 Thömmi


                                          Disclaimer:
                                          Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.

                                          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