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. Longest Function - my submission

Longest Function - my submission

Scheduled Pinned Locked Moved The Lounge
c++htmlcomtoolshelp
15 Posts 10 Posters 1 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.
  • P peterchen

    since it came up yesterday, and I couldn't check. 3643 lines created 1998 "maintained" ever since


    we are here to help each other get through this thing, whatever it is Vonnegut jr.
    boost your code || Fold With Us! || sighist | doxygen

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #4

    And your proud of this? :wtf: RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

    P P 2 Replies Last reply
    0
    • P peterchen

      since it came up yesterday, and I couldn't check. 3643 lines created 1998 "maintained" ever since


      we are here to help each other get through this thing, whatever it is Vonnegut jr.
      boost your code || Fold With Us! || sighist | doxygen

      M Offline
      M Offline
      MohammadAmiry
      wrote on last edited by
      #5

      Can you explain what was your function's function? 'cause in Structured programming, it's no good programming practice to write that long functions and functions are tried to stay short and READABLE.

      P 1 Reply Last reply
      0
      • D Dave Kreskowiak

        And your proud of this? :wtf: RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        P Offline
        P Offline
        ProffK
        wrote on last edited by
        #6

        You're you're you're you're proud. I know, I know

        A 1 Reply Last reply
        0
        • P ProffK

          You're you're you're you're proud. I know, I know

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #7

          Rubbing it in a little! :-D Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fruity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Walliams (Little Britain)

          1 Reply Last reply
          0
          • P peterchen

            since it came up yesterday, and I couldn't check. 3643 lines created 1998 "maintained" ever since


            we are here to help each other get through this thing, whatever it is Vonnegut jr.
            boost your code || Fold With Us! || sighist | doxygen

            N Offline
            N Offline
            Nitron
            wrote on last edited by
            #8

            peterchen wrote: 3643 lines :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: That's child's play! Try 10264 lines. Yea, then we'll talk. (Note: _NOT_ my function, BTW, but I did have to update it :rolleyes: ) Oh yea, and the number of returns in there... :eek: ~Nitron.


            ññòòïðïðB A
            start

            V 1 Reply Last reply
            0
            • N Nitron

              peterchen wrote: 3643 lines :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: That's child's play! Try 10264 lines. Yea, then we'll talk. (Note: _NOT_ my function, BTW, but I did have to update it :rolleyes: ) Oh yea, and the number of returns in there... :eek: ~Nitron.


              ññòòïðïðB A
              start

              V Offline
              V Offline
              V 0
              wrote on last edited by
              #9

              :omg: What does it do then? Certainly it has to calculate the average speed a rocket has to crash into a piece of rock of 10cm³ to create the same amount of energy as the big bang??? ... or something like that?? What does the class do? (and how many lines is that?):wtf: :omg::wtf::rolleyes::wtf::omg::eek::eek: X| X| (get my drift :-D) "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

              J E 2 Replies Last reply
              0
              • V V 0

                :omg: What does it do then? Certainly it has to calculate the average speed a rocket has to crash into a piece of rock of 10cm³ to create the same amount of energy as the big bang??? ... or something like that?? What does the class do? (and how many lines is that?):wtf: :omg::wtf::rolleyes::wtf::omg::eek::eek: X| X| (get my drift :-D) "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

                J Offline
                J Offline
                Joel Holdsworth
                wrote on last edited by
                #10

                V. wrote: Certainly it has to calculate the average speed a rocket has to crash into a piece of rock of 10cm³ to create the same amount of energy as the big bang??? As odd as it sounds, I think you'd be able to do that task with < 100 lines. Although you may run to problems with handling such collosal numbers. Also if you had as much energy as the big bang, it would be likely to cause reality to fail rather quickly I think. And so maybe yes calculating the event could be rather a task. Joel Holdsworth "Outlook not so good" That magic 8-ball knows everything! I'll ask about Exchange Server next

                1 Reply Last reply
                0
                • V V 0

                  :omg: What does it do then? Certainly it has to calculate the average speed a rocket has to crash into a piece of rock of 10cm³ to create the same amount of energy as the big bang??? ... or something like that?? What does the class do? (and how many lines is that?):wtf: :omg::wtf::rolleyes::wtf::omg::eek::eek: X| X| (get my drift :-D) "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

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

                  V. wrote: What does the class do? (and how many lines is that?) Unfortunately, length of class/function does not always equate to lowered functionality. It depends on the type of process. Just as an example, I have my partner's code, rather than build a model-loader for a given 3D model (which would be on the order of 100-500 lines of total complexity including called functions), he uses a Perl program to load the model and convert it to C/C++/OpenGL calls that he can compile into a vertex array, display list, or if I can show him how, a vertex object that he can upload to the graphics card and there it will stay. Thus he has a huge function to "load" a model, vertex descriptions line after line after line. It basically turns into a giant array-member assignment function. So his F4 model is 21021 lines of code T72 tank is 27864 lines example:

                  Models.plots[515].coordinates[0][0]=0.84457;
                  Models.plots[515].coordinates[0][2]=-1.40292;
                  Models.plots[515].coordinates[0][1]=-1.22216;
                  Models.plots[515].coordinates[1][0]=0.84457;
                  Models.plots[515].coordinates[1][2]=-1.40292;
                  Models.plots[515].coordinates[1][1]=-1.22216;
                  Models.plots[515].coordinates[2][0]=0.84457;
                  Models.plots[515].coordinates[2][2]=-1.40292;
                  Models.plots[515].coordinates[2][1]=-1.22216;
                  ...
                  Models.plots[515].coordinates[17][0]=0.83819;
                  Models.plots[515].coordinates[17][2]=-2.15845;
                  Models.plots[515].coordinates[17][1]=0.18664;
                  Models.plots[515].coordinates[18][0]=-1.26778;
                  Models.plots[515].coordinates[18][2]=-1.18953;
                  Models.plots[515].coordinates[18][1]=3.16743;
                  Models.plots[515].coords=19;

                  It is functionally the same, however, not as flexible since to load a new model his requires a recompile, mine does not. However, his perl program strips out anything he doesn't understand about the model, so it always loads. mine, if I forget something it has problems loading the model until I fix the model loader (thus bug). His tends to be more stable on a new format we barely understand, mine requires much better understanding of the model format before it becomes stable. _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                  V 1 Reply Last reply
                  0
                  • E El Corazon

                    V. wrote: What does the class do? (and how many lines is that?) Unfortunately, length of class/function does not always equate to lowered functionality. It depends on the type of process. Just as an example, I have my partner's code, rather than build a model-loader for a given 3D model (which would be on the order of 100-500 lines of total complexity including called functions), he uses a Perl program to load the model and convert it to C/C++/OpenGL calls that he can compile into a vertex array, display list, or if I can show him how, a vertex object that he can upload to the graphics card and there it will stay. Thus he has a huge function to "load" a model, vertex descriptions line after line after line. It basically turns into a giant array-member assignment function. So his F4 model is 21021 lines of code T72 tank is 27864 lines example:

                    Models.plots[515].coordinates[0][0]=0.84457;
                    Models.plots[515].coordinates[0][2]=-1.40292;
                    Models.plots[515].coordinates[0][1]=-1.22216;
                    Models.plots[515].coordinates[1][0]=0.84457;
                    Models.plots[515].coordinates[1][2]=-1.40292;
                    Models.plots[515].coordinates[1][1]=-1.22216;
                    Models.plots[515].coordinates[2][0]=0.84457;
                    Models.plots[515].coordinates[2][2]=-1.40292;
                    Models.plots[515].coordinates[2][1]=-1.22216;
                    ...
                    Models.plots[515].coordinates[17][0]=0.83819;
                    Models.plots[515].coordinates[17][2]=-2.15845;
                    Models.plots[515].coordinates[17][1]=0.18664;
                    Models.plots[515].coordinates[18][0]=-1.26778;
                    Models.plots[515].coordinates[18][2]=-1.18953;
                    Models.plots[515].coordinates[18][1]=3.16743;
                    Models.plots[515].coords=19;

                    It is functionally the same, however, not as flexible since to load a new model his requires a recompile, mine does not. However, his perl program strips out anything he doesn't understand about the model, so it always loads. mine, if I forget something it has problems loading the model until I fix the model loader (thus bug). His tends to be more stable on a new format we barely understand, mine requires much better understanding of the model format before it becomes stable. _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                    V Offline
                    V Offline
                    V 0
                    wrote on last edited by
                    #12

                    Well I didn't understaind your explaination, but the example explains why the function can be so long :-). Have fun counting lines now ... (yes I know linenumbers can be given in VS it was a joke off course). "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

                    E 1 Reply Last reply
                    0
                    • V V 0

                      Well I didn't understaind your explaination, but the example explains why the function can be so long :-). Have fun counting lines now ... (yes I know linenumbers can be given in VS it was a joke off course). "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

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

                      V. wrote: Well I didn't understaind your explaination That's okay... neither does my bosses. One of these days I still hope to master English. Actually, I should learn a second human language so I could blame it on dual language issues rather than just an innability to communicate. :) _________________________ 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
                      • D Dave Kreskowiak

                        And your proud of this? :wtf: RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                        P Offline
                        P Offline
                        peterchen
                        wrote on last edited by
                        #14

                        To paraphrase Tucholsky, "If I weren't proud, I'd still have to maintain it. So I'm rather maintaining and proud"


                        we are here to help each other get through this thing, whatever it is Vonnegut jr.
                        boost your code || Fold With Us! || sighist | doxygen

                        1 Reply Last reply
                        0
                        • M MohammadAmiry

                          Can you explain what was your function's function? 'cause in Structured programming, it's no good programming practice to write that long functions and functions are tried to stay short and READABLE.

                          P Offline
                          P Offline
                          peterchen
                          wrote on last edited by
                          #15

                          It is feeding result windows (about 2 dozen charts and tables) in a huge switch statement with quite some of state information and repetetive code. Yes, that ugly. However, structured programming alone won't help here. At least a state helper object would be required. (to add insult to injury, there is an entity that could happily manage that state. However, the current architecture doesn't allow to use it as such, without doubling the cases) Now, for the more interesting question, why don't I change this? The code works. It currently solves a good hundred teensy little usability problems, both from the math/engineering side (where I am incompetent), and from plain app usage/presentation (where my peers are). It goes into three different products (number growing next month), and is fairly navigatable. Splitting up into functions would not do much good.


                          we are here to help each other get through this thing, whatever it is Vonnegut jr.
                          boost your code || Fold With Us! || sighist | doxygen

                          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