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. Your longuest function!

Your longuest function!

Scheduled Pinned Locked Moved The Lounge
csharpc++swift
44 Posts 14 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.
  • F Frank Kerrigan

    12 Years of marriage! does that count ? -- modified at 4:10 Tuesday 1st August, 2006


    Look where you want to go not where you don't want to crash. Bikers Bible

    G Offline
    G Offline
    Gizzo
    wrote on last edited by
    #18

    Frank Kerrigan wrote:

    12 Years of marriage! does that count ?

    I agree, it's the most difficult part, and you can not debug any line.

    1 Reply Last reply
    0
    • V V 0

      longest class I've ever seen was over 13000 lines long. It contained 8 classes with all the functions scattered through one another. It was VC++. It was the kind of program that gets you the response: "Don't touch that, it works." response. :laugh:

      I've found a living worth working for, but I haven't found work worth living for. :beer:
      :jig:

      G Offline
      G Offline
      Gizzo
      wrote on last edited by
      #19

      18000 lines in 1 class over here...:~

      1 Reply Last reply
      0
      • G Graham Shanks

        Often I find that it is much larger than the method. By the time you add examples of use, pre and post conditions, etc., etc. Graham

        A Offline
        A Offline
        Anna Jayne Metcalfe
        wrote on last edited by
        #20

        They can be. A great deal depends on the size and requirements of the interface.

        Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

        1 Reply Last reply
        0
        • L Lost User

          "It has to fit on one page". Then the boss orders a poster size printer... X|

          The tigress is here :-D

          A Offline
          A Offline
          Anna Jayne Metcalfe
          wrote on last edited by
          #21

          That's why I said A4 ;P

          Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

          E 1 Reply Last reply
          0
          • A Anna Jayne Metcalfe

            It sounds like your boss needs educating in how to code in a maintainable fashion. I'd not let a method longer than about 100 lines through QA, and only then with harsh criticism and a promise to refactor it as soon as practical. If it can't fit on one sheet of A4 comfortably, it's far too long.

            Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

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

            Anna-Jayne Metcalfe wrote:

            I'd not let a method longer than about 100 lines through QA

            pshaw! pedantry and dogma, i say!

            Why donchoo take a peekchur mayn? OK, cleeeeek

            L A 2 Replies Last reply
            0
            • S Super Lloyd

              Well I haven't pay attention to how long mine are. But the fact is, I'm porting my boss's MacOSX application to Windows and I routinely found method over... ... ... 1300 lines of code! :doh: To tone done this fact I should mention it's written in Objective-C which, like C and C++, is quite verbose. And there are (a few) comments. Yet, it's long.... That the size of a class for me! Sometimes I found it tiresome to "translate it" to proper C#...

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

              my largest is around 1100. i'm not proud of it, but it does the job it has to do.

              Why donchoo take a peekchur mayn? OK, cleeeeek

              1 Reply Last reply
              0
              • A Anna Jayne Metcalfe

                It sounds like your boss needs educating in how to code in a maintainable fashion. I'd not let a method longer than about 100 lines through QA, and only then with harsh criticism and a promise to refactor it as soon as practical. If it can't fit on one sheet of A4 comfortably, it's far too long.

                Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

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

                Remember the old windows mesage handlers? They were often into the thousands. It is plain silly to restrict function length and end up with massive amounts of nesting. Not only does it read really badly it is a lot slower.

                Truth is the subjection of reality to an individuals perception

                A 1 Reply Last reply
                0
                • C Chris Losinger

                  Anna-Jayne Metcalfe wrote:

                  I'd not let a method longer than about 100 lines through QA

                  pshaw! pedantry and dogma, i say!

                  Why donchoo take a peekchur mayn? OK, cleeeeek

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

                  Yep, a case of 'follow the code standard' regardless of its bottom line impact.

                  Truth is the subjection of reality to an individuals perception

                  1 Reply Last reply
                  0
                  • C Chris Losinger

                    Anna-Jayne Metcalfe wrote:

                    I'd not let a method longer than about 100 lines through QA

                    pshaw! pedantry and dogma, i say!

                    Why donchoo take a peekchur mayn? OK, cleeeeek

                    A Offline
                    A Offline
                    Anna Jayne Metcalfe
                    wrote on last edited by
                    #26

                    Nope...self interest - I'd probably end up maintaining the thing! ;P

                    Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

                    1 Reply Last reply
                    0
                    • L Lost User

                      Remember the old windows mesage handlers? They were often into the thousands. It is plain silly to restrict function length and end up with massive amounts of nesting. Not only does it read really badly it is a lot slower.

                      Truth is the subjection of reality to an individuals perception

                      A Offline
                      A Offline
                      Anna Jayne Metcalfe
                      wrote on last edited by
                      #27

                      In case you hadn't noticed, very few people write Windows apps in C these days, so that really isn't relevant. If the design is right, you really shouldn't end up with excessive nesting. :rose:

                      Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

                      L E S 3 Replies Last reply
                      0
                      • S Super Lloyd

                        Well I haven't pay attention to how long mine are. But the fact is, I'm porting my boss's MacOSX application to Windows and I routinely found method over... ... ... 1300 lines of code! :doh: To tone done this fact I should mention it's written in Objective-C which, like C and C++, is quite verbose. And there are (a few) comments. Yet, it's long.... That the size of a class for me! Sometimes I found it tiresome to "translate it" to proper C#...

                        E Offline
                        E Offline
                        El Corazon
                        wrote on last edited by
                        #28

                        Super Lloyd wrote:

                        But the fact is, I'm porting my boss's MacOSX application to Windows and I routinely found method over... ... ... 1300 lines of code

                        Now see you ask for ours... but you are quoting your boss' application. I think my largest function, again is a switch statement, probably smaller than this one, but several hundred lines. However... I took over a project once where the lady wrote the entire program in main() no function calls at all, repetitive operations were handled by cut-n-paste and changing variable names. It was somewhere on the order of 50,000 lines or more. I was told not to rewrite it because that would declare that the original was "bad," so I "refactored it" instead. :laugh:

                        _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                        S 1 Reply Last reply
                        0
                        • A Anna Jayne Metcalfe

                          In case you hadn't noticed, very few people write Windows apps in C these days, so that really isn't relevant. If the design is right, you really shouldn't end up with excessive nesting. :rose:

                          Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

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

                          Who mentioned C? A non MFC app can have a defwindowproc in C++. Design has nothing to do with implementation, and in many cases huge switch statements are the best implementation.

                          Truth is the subjection of reality to an individuals perception

                          A 1 Reply Last reply
                          0
                          • E El Corazon

                            Super Lloyd wrote:

                            But the fact is, I'm porting my boss's MacOSX application to Windows and I routinely found method over... ... ... 1300 lines of code

                            Now see you ask for ours... but you are quoting your boss' application. I think my largest function, again is a switch statement, probably smaller than this one, but several hundred lines. However... I took over a project once where the lady wrote the entire program in main() no function calls at all, repetitive operations were handled by cut-n-paste and changing variable names. It was somewhere on the order of 50,000 lines or more. I was told not to rewrite it because that would declare that the original was "bad," so I "refactored it" instead. :laugh:

                            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                            S Offline
                            S Offline
                            Super Lloyd
                            wrote on last edited by
                            #30

                            Jeffry J. Brickley wrote:

                            Now see you ask for ours... but you are quoting your boss' application

                            :->

                            Jeffry J. Brickley wrote:

                            took over a project once where the lady wrote the entire program in main() no function calls at all, repetitive operations were handled by cut-n-paste and changing variable names. It was somewhere on the order of 50,000 lines or more. I was told not to rewrite it because that would declare that the original was "bad," so I "refactored it" instead.

                            Not bad hey! Even politicaly correct! :laugh:

                            E 1 Reply Last reply
                            0
                            • A Anna Jayne Metcalfe

                              That's why I said A4 ;P

                              Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

                              E Offline
                              E Offline
                              El Corazon
                              wrote on last edited by
                              #31

                              Anna-Jayne Metcalfe wrote:

                              That's why I said A4

                              but did you specify font size? I used to print 4x1 on each size of standard sheets to save paper. I've even still got the magnifying glass on the shelf above me even though I haven't done that in quite a while. I will still do it for nVidia technology papers, the strain of reading them keeps me from falling asleep from the lack of plot.

                              _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                              A 1 Reply Last reply
                              0
                              • S Super Lloyd

                                Jeffry J. Brickley wrote:

                                Now see you ask for ours... but you are quoting your boss' application

                                :->

                                Jeffry J. Brickley wrote:

                                took over a project once where the lady wrote the entire program in main() no function calls at all, repetitive operations were handled by cut-n-paste and changing variable names. It was somewhere on the order of 50,000 lines or more. I was told not to rewrite it because that would declare that the original was "bad," so I "refactored it" instead.

                                Not bad hey! Even politicaly correct! :laugh:

                                E Offline
                                E Offline
                                El Corazon
                                wrote on last edited by
                                #32

                                Super Lloyd wrote:

                                Your longuest function!

                                fess up! what is yours?? :-D

                                _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                S 1 Reply Last reply
                                0
                                • A Anna Jayne Metcalfe

                                  In case you hadn't noticed, very few people write Windows apps in C these days, so that really isn't relevant. If the design is right, you really shouldn't end up with excessive nesting. :rose:

                                  Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

                                  E Offline
                                  E Offline
                                  El Corazon
                                  wrote on last edited by
                                  #33

                                  Anna-Jayne Metcalfe wrote:

                                  In case you hadn't noticed, very few people write Windows apps in C these days, so that really isn't relevant.

                                  you mean I am a minority again?

                                  Anna-Jayne Metcalfe wrote:

                                  If the design is right, you really shouldn't end up with excessive nesting.

                                  part of it has to do with language. Pixel shader 3 finally allowed more use of high level programming structure. There was actually some people against it. Looping in parallel synced operations is dangerous to the efficiency. You've got 24 pipes and one decides to loop due to an exceptional condition and the other 23 idle waiting for it to finish. There was/is still strong resistance to function calls, loops, and high level design techniques that can shorten nested code, but result in more overhead to the compiler/CPU/GPU.

                                  _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                  1 Reply Last reply
                                  0
                                  • S Super Lloyd

                                    Well I haven't pay attention to how long mine are. But the fact is, I'm porting my boss's MacOSX application to Windows and I routinely found method over... ... ... 1300 lines of code! :doh: To tone done this fact I should mention it's written in Objective-C which, like C and C++, is quite verbose. And there are (a few) comments. Yet, it's long.... That the size of a class for me! Sometimes I found it tiresome to "translate it" to proper C#...

                                    E Offline
                                    E Offline
                                    Ennis Ray Lynch Jr
                                    wrote on last edited by
                                    #34

                                    a 128 statement if in c++ once. (Actually 2 because I had to break off into a method call for the rest)

                                    A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

                                    S 1 Reply Last reply
                                    0
                                    • E El Corazon

                                      Super Lloyd wrote:

                                      Your longuest function!

                                      fess up! what is yours?? :-D

                                      _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                      S Offline
                                      S Offline
                                      Super Lloyd
                                      wrote on last edited by
                                      #35

                                      My Code is perfect! ;P Hu.. I don't know. Except when working with other people's work I think I never wrote absurdly long function. Although I confess I did write classes I found too .... big and intertwinned. I remember a Java project in 2003. I had a Java class... ahumm.. ~3000 lines long (I know it's little player, but at the time that was my longuest class) and it was awfully messy. Lots of variable, and many variables using in plenty of different function which makes it higly .. surprizing shall I say? I just checked in my current project my most complex class / code. The worst class / file is only 4054 lines.... I guess I can't stand big files, so I avoid it... ;) ON the other hand I have a file of 400.000 lines. But it's autogenerated!

                                      1 Reply Last reply
                                      0
                                      • E Ennis Ray Lynch Jr

                                        a 128 statement if in c++ once. (Actually 2 because I had to break off into a method call for the rest)

                                        A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

                                        S Offline
                                        S Offline
                                        Super Lloyd
                                        wrote on last edited by
                                        #36

                                        Now you're talking! :omg:

                                        1 Reply Last reply
                                        0
                                        • J J Dunlap

                                          :-O I've got a method about 230 lines long (with a lot of comments). It's the main method for a full-fledged table layout algorithm that has: * col/row width options such as fit-to-content, percent, and absolute * the ability to choose which rows/cols get "crushed" or get collapsed when things don't fit * choice of which rows/cols if any are widened to fit the remaining layout area * space prioritization for rows/cols * repeating rows/cols * at least several other features I've broken up the functionality into at least 15 methods, but the main function is still too big for my liking. -- modified at 5:03 Tuesday 1st August, 2006

                                          S Offline
                                          S Offline
                                          Super Lloyd
                                          wrote on last edited by
                                          #37

                                          I say, that's allright?! :laugh:

                                          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