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. Fighting a monster

Fighting a monster

Scheduled Pinned Locked Moved The Lounge
question
68 Posts 34 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.
  • M Mircea Neacsu

    I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

    Mircea

    S Offline
    S Offline
    Sri Krishna
    wrote on last edited by
    #25

    Around 10 years back, I joined my first company, where I was introduced to a codebase which was in Java/XML, kind of an Android Application. I saw files having 12k lines. It was a nightmare situation for me to even navigate the code and to follow up on a bug we were supposed to fix! As we progressed through the years, we found lower lines per file, saw IDE limiters on number of lines in a File(Max 1000), saw Coding Architectures like MVX(MVP, MVVM, MVI, etc.) asking us to break up code blocks into smaller more testable modules, saw Testing Tooling and other advice from many asking us to test a smallest unit. Overall, the experience is a very rewarding, at each step we learnt the mistake we did previously, made amends and then made some more mistakes :laugh: and then fixed them in the coming months.

    N T 2 Replies Last reply
    0
    • M Mircea Neacsu

      I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

      Mircea

      W Offline
      W Offline
      Wizard of Sleeves
      wrote on last edited by
      #26

      Hello World is about 10 000 lines of code in C++

      Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.

      1 Reply Last reply
      0
      • S Slacker007

        Line count is not a default metric for me. If all the code is concise and organized well and has purpose, who cares about line count...I don't.

        Sander RosselS Offline
        Sander RosselS Offline
        Sander Rossel
        wrote on last edited by
        #27

        Slacker007 wrote:

        If all the code is concise and organized well and has purpose

        Which is almost never the case in a 9k lines file ;)

        Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

        D T 2 Replies Last reply
        0
        • M Mircea Neacsu

          I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

          Mircea

          Sander RosselS Offline
          Sander RosselS Offline
          Sander Rossel
          wrote on last edited by
          #28

          I don't know the largest file I've ever worked with, but I currently have a project with about a 4k lines file. It's a VB.NET WinForms file. The form draws lines and squares onto a picture. Imagine a plot of farm land on the picture, and the form's functionality drawing the plot's outer edges and separating them into x strips. That's what it does and all the logic is in that single form. Unfortunately, there is no clear naming convention, so a variable can be named "square" in one function and a "box" in another. The form has over 90 fields, which I all have to take into account whenever I change something. I know the original developer, and he had a lot of trouble writing this, probably because he's very bad at dividing a problem into smaller sub-problems. Or maybe because he's a real shitty developer. Luckily, it works most of the time, but if it doesn't work it stresses me out and I propose a rewrite. I think this is the only code in my entire career I dare not touch :sigh:

          Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

          1 Reply Last reply
          0
          • T trønderen

            DerekT-P wrote:

            the listing was frequently annotated by hand

            Wasn't that common practice in the 1970s-80s? In my student days, I was an intern in a company making 16bit minis and 32bit superminis, running their own OS (in those days, 'Unix' was hardly known at all outside universities). I managed to isolate a bug in the OS, and went to the responsible guy. For quite a while, he flipped back and forth in his huge OS source printout, before exclaiming a "There!", dug out his ballpoint pen and wrote the code fix into the listing. What makes me remember it better than I would otherwise: This OS was written in a language about midway between assembler and K&R C. He didn't write his fix in that language. He didn't write the assembler instructions. He wrote down the numeric instruction codes, in octal format. I guess that this qualifies for being an 'oldtimer' :-)

            D Offline
            D Offline
            DerekT P
            wrote on last edited by
            #29

            Guess the fix might have been just directly manipulating the binary executable. Have had to do that a few times. Other than that, the places I worked were usually quite good at keeping up-to-date hard copy listings. But then this was before VDUs. We also, of course, had the card decks, and they were all carefully maintained and filed. We even had a card printer that would read a punched card and type the contents along the top. Useful, as though most of the punching was done by the girls (and only girls) in the punchroom - whose machines printed the text on the cards - we also had access to a punch machine for doing the occasional edit, and that one didn't print. So looking through a deck you'd come to a revision but didn't know what the code was. (Well, you could just hold it up to the light and read it - became second nature after a while!)

            Telegraph marker posts ... nothing to do with IT Phasmid email discussion group ... also nothing to do with IT Beekeeping and honey site ... still nothing to do with IT

            T 1 Reply Last reply
            0
            • M Mircea Neacsu

              I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

              Mircea

              D Offline
              D Offline
              Derek Hunter
              wrote on last edited by
              #30

              I'm working on a 17,000 line Python script now and it doesn't feel particularly unwieldy.

              1 Reply Last reply
              0
              • M Mircea Neacsu

                I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

                Mircea

                D Offline
                D Offline
                den2k88
                wrote on last edited by
                #31

                Mircea Neacsu wrote:

                Got me wondering: what's the largest single source file you ever met?

                12 thousands line of C code, without any indentation at all and scant comments.

                GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                1 Reply Last reply
                0
                • S Sri Krishna

                  Around 10 years back, I joined my first company, where I was introduced to a codebase which was in Java/XML, kind of an Android Application. I saw files having 12k lines. It was a nightmare situation for me to even navigate the code and to follow up on a bug we were supposed to fix! As we progressed through the years, we found lower lines per file, saw IDE limiters on number of lines in a File(Max 1000), saw Coding Architectures like MVX(MVP, MVVM, MVI, etc.) asking us to break up code blocks into smaller more testable modules, saw Testing Tooling and other advice from many asking us to test a smallest unit. Overall, the experience is a very rewarding, at each step we learnt the mistake we did previously, made amends and then made some more mistakes :laugh: and then fixed them in the coming months.

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #32

                  Sri Krishna wrote:

                  at each step we learnt the mistake we did previously, made amends and then made some more mistakes :laugh: and then fixed them in the coming months.

                  Life experience is exactly the same. Nobody know everything from the beginning.

                  M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                  1 Reply Last reply
                  0
                  • T trønderen

                    DerekT-P wrote:

                    the listing was frequently annotated by hand

                    Wasn't that common practice in the 1970s-80s? In my student days, I was an intern in a company making 16bit minis and 32bit superminis, running their own OS (in those days, 'Unix' was hardly known at all outside universities). I managed to isolate a bug in the OS, and went to the responsible guy. For quite a while, he flipped back and forth in his huge OS source printout, before exclaiming a "There!", dug out his ballpoint pen and wrote the code fix into the listing. What makes me remember it better than I would otherwise: This OS was written in a language about midway between assembler and K&R C. He didn't write his fix in that language. He didn't write the assembler instructions. He wrote down the numeric instruction codes, in octal format. I guess that this qualifies for being an 'oldtimer' :-)

                    M Offline
                    M Offline
                    Mircea Neacsu
                    wrote on last edited by
                    #33

                    Your and Derek’s stories remind me of a life lesson from the same era. As a young uni student, I was fighting with an assembly language program and the assembler was giving all kind of strange error messages. Showing the problem to the TA I was working with, he didn’t figure it out either and sent me to author of the assembler, a guy just a few years older than me. He looked at the problem and went: “yes, I see what’s going on, come back in the afternoon for a solution”. In the afternoon, he gave me a single punched card to add to the deck of punched cards that was the assembler program - in those days you loaded the assembler from punch cards - and that indeed solved my strange error. For me the whole thing was almost like magic. Some time later I figured the error had to do with the evaluation to different values of a symbol during different assembler passes and what the guy did was to make a binary patch that fixed the problem. Why I say it was a life lesson for me? When I saw that guy figuring out quickly a problem that had both me and the TA stumped, and giving such an elegant solution (a single punched card), the young, cocky me realized there are people much smarter than me in the world and some humility is always in order.

                    Mircea

                    1 Reply Last reply
                    0
                    • M Mircea Neacsu

                      I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

                      Mircea

                      M Offline
                      M Offline
                      MadGerbil
                      wrote on last edited by
                      #34

                      I think the opposite situation is even worse. You get some abstraction/interface monkey at the keyboard and you may find yourself jumping through a dozen different 5 line files to get to the actual code that adds X + Y. Tons and tons of code written to handle the unlikely event that your boss is going to walk into your office one day and say, "Hey, let switch from Oracle to SQL". I understand some vended products feel the need to support that, but they don't.

                      G M W T J 5 Replies Last reply
                      0
                      • M MadGerbil

                        I think the opposite situation is even worse. You get some abstraction/interface monkey at the keyboard and you may find yourself jumping through a dozen different 5 line files to get to the actual code that adds X + Y. Tons and tons of code written to handle the unlikely event that your boss is going to walk into your office one day and say, "Hey, let switch from Oracle to SQL". I understand some vended products feel the need to support that, but they don't.

                        G Offline
                        G Offline
                        Gary Wheeler
                        wrote on last edited by
                        #35

                        MadGerbil wrote:

                        You get some abstraction/interface monkey at the keyboard

                        Yes. I have a former coworker who was Mr. Object. He took three or more abstraction layers to do just about anything, no function was more than 8 or 10 lines, and it was difficult to follow. Fortunately Intellisense in later versions of Visual Studio (this is C++) works well enough that navigation isn't limited to "Find-in-files, edit, rinse, repeat."

                        Software Zen: delete this;

                        1 Reply Last reply
                        0
                        • M MadGerbil

                          I think the opposite situation is even worse. You get some abstraction/interface monkey at the keyboard and you may find yourself jumping through a dozen different 5 line files to get to the actual code that adds X + Y. Tons and tons of code written to handle the unlikely event that your boss is going to walk into your office one day and say, "Hey, let switch from Oracle to SQL". I understand some vended products feel the need to support that, but they don't.

                          M Offline
                          M Offline
                          Mircea Neacsu
                          wrote on last edited by
                          #36

                          "Abstraction monkey" I like that! Can I use it? :laugh:

                          Mircea

                          M 1 Reply Last reply
                          0
                          • M Mircea Neacsu

                            "Abstraction monkey" I like that! Can I use it? :laugh:

                            Mircea

                            M Offline
                            M Offline
                            MadGerbil
                            wrote on last edited by
                            #37

                            Wouldn't IMonkey be better? Just to be safe. :-D

                            E 1 Reply Last reply
                            0
                            • M Mircea Neacsu

                              I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

                              Mircea

                              R Offline
                              R Offline
                              rnbergren
                              wrote on last edited by
                              #38

                              many years ago. I was hired on to take over an outsourced application. The devs for the outsourced app had never heard of libraries or headers or includes etc.. So therefore they had replicated all the various functions and other things that the program relied on into the the top of every file in the entire project. and they only wrote code in Notepad. Not notepad++ or something decent. Windows notepad. They also command line compiled the whole thing. (not c or C++) it was this weird complex development of C# and VB.net. And yes you can command line compile and open the thing in NotePad. But why would you. So I spent my first 6 months just rewritting the entire thing and creating includes and dll's etc.. and putting the whole thing into Visual Studio so it could be compiled. Oh and did I mention Source Control. Yep implemented that as well. Largest file was well over 9k lines. When done. I don't think anything was over 100. I don't miss that job.

                              To err is human to really elephant it up you need a computer

                              E 1 Reply Last reply
                              0
                              • T trønderen

                                DerekT-P wrote:

                                the listing was frequently annotated by hand

                                Wasn't that common practice in the 1970s-80s? In my student days, I was an intern in a company making 16bit minis and 32bit superminis, running their own OS (in those days, 'Unix' was hardly known at all outside universities). I managed to isolate a bug in the OS, and went to the responsible guy. For quite a while, he flipped back and forth in his huge OS source printout, before exclaiming a "There!", dug out his ballpoint pen and wrote the code fix into the listing. What makes me remember it better than I would otherwise: This OS was written in a language about midway between assembler and K&R C. He didn't write his fix in that language. He didn't write the assembler instructions. He wrote down the numeric instruction codes, in octal format. I guess that this qualifies for being an 'oldtimer' :-)

                                E Offline
                                E Offline
                                englebart
                                wrote on last edited by
                                #39

                                Was it an HP? HP seemed to love Octal. 12bit bytes/words work well with Octal.

                                T 1 Reply Last reply
                                0
                                • M Mircea Neacsu

                                  I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

                                  Mircea

                                  D Offline
                                  D Offline
                                  dandy72
                                  wrote on last edited by
                                  #40

                                  A project I inherited had a 1200-line function, duplicated 7 times, each with slightly different input parameters and doing something slightly different. Very subtle differences, which were easy to miss. I spent weeks trying to refactor it and deduplicate as much code as I could. I think in the end I had a single function, 700 lines long, that took in a few more input params than the 7 original functions, and branched off on those as appropriate in the code. I was still not satisfied with it, and frankly I'd still rather not even think about it. It was written by one of the company founders, who should never have been allowed anywhere near a compiler. [going on a tangent, you got me started] :-) I spent an awful lot of time trying to convince him something he had in mind couldn't be done, unless he intended to have someone dedicated full-time to keeping that code up to date, as the data it needed to gather came from different software companies that didn't talk to each other or standardize on anything and could change on a whim. The data was never intended to be read by third-parties, so they could change format as often as they wanted (and they did). He wasn't happy with my justification, so he then decided to take it upon himself to "write it in a weekend"...come Monday morning, he had something that worked, which he showed to other people (who didn't know any better) who complimented him on the work and decided to commit to it, and why couldn't I have come up with that since it only took the other guy two days to do it. His code was only compatible with the data produced by one version of the third-party software he was working with. Nothing else. And within a week it was broken because the data format had changed.

                                  M 1 Reply Last reply
                                  0
                                  • M Mircea Neacsu

                                    I started to dive in a new (for me) very large code base. One of the files is 9500 lines. Got me wondering: what's the largest single source file you ever met? I'm not talking about automatically generated source files, but those written by humans. On the same note, when do you think it's time to break a file in smaller pieces? For me, it is somewhere around 1000 lines.

                                    Mircea

                                    W Offline
                                    W Offline
                                    WPerkins
                                    wrote on last edited by
                                    #41

                                    In the COBOL days 20K lines per source was not uncommon. But then, that was COBOL.

                                    T 1 Reply Last reply
                                    0
                                    • M MadGerbil

                                      Wouldn't IMonkey be better? Just to be safe. :-D

                                      E Offline
                                      E Offline
                                      englebart
                                      wrote on last edited by
                                      #42

                                      IUnknownMonkey At least that way you can query it for standard interfaces that are supported as well as the monkey business interfaces.

                                      1 Reply Last reply
                                      0
                                      • D dandy72

                                        A project I inherited had a 1200-line function, duplicated 7 times, each with slightly different input parameters and doing something slightly different. Very subtle differences, which were easy to miss. I spent weeks trying to refactor it and deduplicate as much code as I could. I think in the end I had a single function, 700 lines long, that took in a few more input params than the 7 original functions, and branched off on those as appropriate in the code. I was still not satisfied with it, and frankly I'd still rather not even think about it. It was written by one of the company founders, who should never have been allowed anywhere near a compiler. [going on a tangent, you got me started] :-) I spent an awful lot of time trying to convince him something he had in mind couldn't be done, unless he intended to have someone dedicated full-time to keeping that code up to date, as the data it needed to gather came from different software companies that didn't talk to each other or standardize on anything and could change on a whim. The data was never intended to be read by third-parties, so they could change format as often as they wanted (and they did). He wasn't happy with my justification, so he then decided to take it upon himself to "write it in a weekend"...come Monday morning, he had something that worked, which he showed to other people (who didn't know any better) who complimented him on the work and decided to commit to it, and why couldn't I have come up with that since it only took the other guy two days to do it. His code was only compatible with the data produced by one version of the third-party software he was working with. Nothing else. And within a week it was broken because the data format had changed.

                                        M Offline
                                        M Offline
                                        Mircea Neacsu
                                        wrote on last edited by
                                        #43

                                        dandy72 wrote:

                                        decided to take it upon himself to "write it in a weekend"

                                        Hey, I heard of another CEO who wrote FAT on an airplane, for heaven's sake[^] :laugh:

                                        Mircea

                                        T 1 Reply Last reply
                                        0
                                        • T trønderen

                                          DerekT-P wrote:

                                          the listing was frequently annotated by hand

                                          Wasn't that common practice in the 1970s-80s? In my student days, I was an intern in a company making 16bit minis and 32bit superminis, running their own OS (in those days, 'Unix' was hardly known at all outside universities). I managed to isolate a bug in the OS, and went to the responsible guy. For quite a while, he flipped back and forth in his huge OS source printout, before exclaiming a "There!", dug out his ballpoint pen and wrote the code fix into the listing. What makes me remember it better than I would otherwise: This OS was written in a language about midway between assembler and K&R C. He didn't write his fix in that language. He didn't write the assembler instructions. He wrote down the numeric instruction codes, in octal format. I guess that this qualifies for being an 'oldtimer' :-)

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

                                          The first program I wrote was in machine code using hex notation. I then had to key it in by hand using the buttons on the front panel of the processor.

                                          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