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.
  • P PIEBALDconsult

    What language? C# should never have been released to the wild without partial classes. :mad: For me, it's not directly about the size. I wouldn't break up a file simply because it's larger than X units. The point is that being "too big" can make things hard to find, and "too hard to find" is what matters more than simply "size". Similarly, having two pieces of code in separate files makes it easier to have them open in two windows beside each other for whatever reason you may need to do that. Splitting the code for an application into several files makes version control easier and reduces change conflicts when multiple developers are working on the same code base. And code sharing between unrelated applications is easier when the applications share a minimum of code and don't share code they don't actually rely on. The lower and more common the code is, the more granular it should be. My library code is in single-method (possibly a family of overloaded methods) files, and each application can include only the parts it requires. Higher level -- application-specific -- code should probably be separated more by functional area; frontend, backend, configuration, administration, etc. Multi-file projects just make everything better for a team of developers. Size itself doesn't matter.

    H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #6

    I *wish* C++14 and above had partial classes

    To err is human. Fortune favors the monsters.

    P D 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

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #7

      No idea of the lines count, but almost certainly assembler code: maybe 1/2MB or thereabouts? The assembler we were using only supported single files: no includes, no relocatable blocks, no linker. For a 32KB ROM, that's only 16 chars per line so it's probably about right - maybe a little conservative. Since the ROM was full, and most common instructions one byte long, maybe 28K lines or so?

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • H honey the codewitch

        I *wish* C++14 and above had partial classes

        To err is human. Fortune favors the monsters.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #8

        You can't split a class into multiple files in C++ to be compiled together into one executable? I'm pretty sure you can, but I only ever dabbled in C++ back in the day. Or are you saying that you want to have different parts of a class compiled into separate executables (DLLs)?

        H M 2 Replies Last reply
        0
        • P PIEBALDconsult

          You can't split a class into multiple files in C++ to be compiled together into one executable? I'm pretty sure you can, but I only ever dabbled in C++ back in the day. Or are you saying that you want to have different parts of a class compiled into separate executables (DLLs)?

          H Offline
          H Offline
          honey the codewitch
          wrote on last edited by
          #9

          No, it would be nice to be able to declare a class twice in two different files and have it compiled into the same binary. C++ does not let you do that, at least not to my knowledge, unless they added it after C++17. For example, I have a draw class that handles all the drawing operations in my graphics library. It would be nice to segregate the different drawing primitives into different files, but the only way to do that is to delegate and forward or to use multiple C++ implementation files for a single class, but you still wind up with all the method definitions for all the drawing primitives in the same header. You can hack around it using the preprocessor, by #includeing class fragments, but that's techy. Edit: You can use inheritance to approximate it, but that still runs you into visibility issues.

          To err is human. Fortune favors the monsters.

          P 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
            DerekT P
            wrote on last edited by
            #10

            Well, it was a long time ago but back in pre-history when I was writing COBOL (no longer on cards thank God) the main program in an overnight suite I supported was (I think) 21,000 lines of code (well, code + blank space). We did everything we could to avoid printing the thing (360 pages), so the listing was frequently annotated by hand. Of course that didn't really help when the actual code had typos that still allowed it to compile. As overnight on-call support, I'd frequently get bleeped (by pager) and have to hook up the 600baud teletype to my landline, and get the relevant bits of memory dump. (Most issues were S0C7 faults). Yes, for some reason data was never properly validated; actual code bugs were rare, but get a non-numeric character in a character column in data and the whole shooting match failed.

            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

              R Offline
              R Offline
              Rick York
              wrote on last edited by
              #11

              I have to deal with a program that has several files, one of which is 88K lines and about 2.5MB. To add to the misery, there are thousands of global variables. We have rewritten most applications based on this but not all of them and it's an on-going thing.

              "They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"

              1 Reply Last reply
              0
              • P PIEBALDconsult

                You can't split a class into multiple files in C++ to be compiled together into one executable? I'm pretty sure you can, but I only ever dabbled in C++ back in the day. Or are you saying that you want to have different parts of a class compiled into separate executables (DLLs)?

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

                Yes, you can. Class definition has to stay in one file but implementation can go in any number of files.

                Mircea

                P 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

                  Mike HankeyM Offline
                  Mike HankeyM Offline
                  Mike Hankey
                  wrote on last edited by
                  #13

                  Anything past one pizza.

                  PartsBin an Electronics Part Organizer - An updated version available! JaxCoder.com Latest Article: ARM Tutorial Part 1 Clocks

                  1 Reply Last reply
                  0
                  • H honey the codewitch

                    No, it would be nice to be able to declare a class twice in two different files and have it compiled into the same binary. C++ does not let you do that, at least not to my knowledge, unless they added it after C++17. For example, I have a draw class that handles all the drawing operations in my graphics library. It would be nice to segregate the different drawing primitives into different files, but the only way to do that is to delegate and forward or to use multiple C++ implementation files for a single class, but you still wind up with all the method definitions for all the drawing primitives in the same header. You can hack around it using the preprocessor, by #includeing class fragments, but that's techy. Edit: You can use inheritance to approximate it, but that still runs you into visibility issues.

                    To err is human. Fortune favors the monsters.

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

                    Hmm, odd, I was sure I had done that back in the 80s or 90s. I must be mistaken. PIEBALD goes spelunking and finds some old C++ code... Ah, you are correct (of course), I was mistaken for the most part. I see by my code that the class has to be defined in one place, but that the implementations of the members can be separated out into other files -- and I'm using #include to combine the code together. When C# 1 was first released, a class had to be fully defined and implemented in one file -- which was horrible -- but C# 2 added partial classes (and interfaces), with which a class definition and implementation can be spread across multiple files. I do see that something similar could probably be accomplished with C++ (and maybe C# 1) by using the C-preprocessor, but that wouldn't be as clean.

                    1 Reply Last reply
                    0
                    • M Mircea Neacsu

                      Yes, you can. Class definition has to stay in one file but implementation can go in any number of files.

                      Mircea

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

                      But with C# (2 and newer), the definition can also be spread across files; not just the implementation. C# combines the definition and implementation together (other than abstract members).

                      M 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        But with C# (2 and newer), the definition can also be spread across files; not just the implementation. C# combines the definition and implementation together (other than abstract members).

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

                        I know, but my monster is C/C++ :-D

                        Mircea

                        P 1 Reply Last reply
                        0
                        • M Mircea Neacsu

                          I know, but my monster is C/C++ :-D

                          Mircea

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #17

                          If it ain't broke, don't break it.

                          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

                            T Offline
                            T Offline
                            trønderen
                            wrote on last edited by
                            #18

                            I was told two extreme cases from the software for the ITT System 12 phone switch: The largest 'struct' definition (the language used was CHILL, not C, so terms are different) ran to 8300 lines. Printed 72 lines per page, this single type definition would fill a 115 page book. The linker for this system maintained a symbol export table for each module. Early linker versions used a signed 16-bit integer to index this table, so it was limited to 32768 exported symbols. This limit was exceeded - System 12 defined modules exporting more than 32 Ki symbols. I can understand importing that many symbols, but exporting from a single module!?! The maintainer of this linker was a university classmate of mine (he was the one telling about that struct, too) told that they made a quick fix, changing the index type to unsigned integer, to allow for 65536 exported symbols. But if anyone can break a 32 Ki limit, they can break a 64 Ki limit, too. So in the next major revision, the index type was changed to 32 bits. Hopefully, noone will export more than 4 billion symbols from a single module :-)

                            1 Reply Last reply
                            0
                            • D DerekT P

                              Well, it was a long time ago but back in pre-history when I was writing COBOL (no longer on cards thank God) the main program in an overnight suite I supported was (I think) 21,000 lines of code (well, code + blank space). We did everything we could to avoid printing the thing (360 pages), so the listing was frequently annotated by hand. Of course that didn't really help when the actual code had typos that still allowed it to compile. As overnight on-call support, I'd frequently get bleeped (by pager) and have to hook up the 600baud teletype to my landline, and get the relevant bits of memory dump. (Most issues were S0C7 faults). Yes, for some reason data was never properly validated; actual code bugs were rare, but get a non-numeric character in a character column in data and the whole shooting match failed.

                              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 Offline
                              T Offline
                              trønderen
                              wrote on last edited by
                              #19

                              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 M E L 4 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

                                T Offline
                                T Offline
                                trønderen
                                wrote on last edited by
                                #20

                                Original Pascal had no module concept. All code had to go in a single file. Open source is not as new as Linux people will make us believe! The Pascal P4 compiler was always freely available. I picked it up as a university freshman and studied on my own alongside working on the '101 Introduction to Programming' hand-in exercises. I'll say that it gave me a head start in programming ... The compiler source was between 30,000 and 35,000 lines. For quite a few years following, I was really bothered by the upcoming C source file common practice of creating a separate file for every single function: How can you find anything at all in the source when you have to open hundreds of files for searching? Tools for searching across an entire directory tree wasn't very developed then - not until the C practice had become more widespread. Today we have the tools. We also have FOSS. Even today I am appalled when I have to handle a zillion files, each containing 70-100 lines of open source license/copyleft blurb, followed by a five line function. In every single one of a zillion files!

                                1 Reply Last reply
                                0
                                • L Lost User

                                  Oil and gas FORTRAN programs would typically run that long. No comments. 8 letter names. Engineers. My source gets split when it's description gets too cumbersome (indicating code smell): e.g. "the charge, pursuit, retreat adapter".

                                  "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                                  T Offline
                                  T Offline
                                  trønderen
                                  wrote on last edited by
                                  #21

                                  A couple of weeks ago, I told the story about the Fortran compiler that had to be extended (actually, replaced by a completely new one) to handle one customer's Fortran function, having more than the old compiler's limit of 99 arguments. I have no information about the number of lines in the function. Even partial classes won't allow a single function / method to be spread over several files.

                                  L 1 Reply Last reply
                                  0
                                  • H honey the codewitch

                                    I *wish* C++14 and above had partial classes

                                    To err is human. Fortune favors the monsters.

                                    D Offline
                                    D Offline
                                    Daniel Pfeffer
                                    wrote on last edited by
                                    #22

                                    You certainly can declare a class in a single .h file and have the implementation spread over multiple .cpp files. That has been possible since ARM C++.

                                    Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                                    H 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
                                      Mircea Neacsu
                                      wrote on last edited by
                                      #23

                                      Thank you all for replying to my question. I understood that: a) I'm a wimp for complaining about size. b) Almost everyone thinks "my (source code) is bigger than yours" - honi soit qui mal y pense :)

                                      Mircea

                                      1 Reply Last reply
                                      0
                                      • D Daniel Pfeffer

                                        You certainly can declare a class in a single .h file and have the implementation spread over multiple .cpp files. That has been possible since ARM C++.

                                        Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                                        H Offline
                                        H Offline
                                        honey the codewitch
                                        wrote on last edited by
                                        #24

                                        Sure, but you wind up with an .h file with all the declarations for the class in it, regardless. :(

                                        To err is human. Fortune favors the monsters.

                                        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

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