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. Lines of code

Lines of code

Scheduled Pinned Locked Moved The Lounge
question
33 Posts 20 Posters 3 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.
  • B Bart

    A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

    bart

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #5

    The lines generated by a tool are generally boilerplate, VS does not write code in any meaningful way, it just generates standard lines, like event handlers, when you tell it to. so, you wrote it all.

    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

    B A 2 Replies Last reply
    0
    • B Bart

      A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

      bart

      B Offline
      B Offline
      bryce
      wrote on last edited by
      #6

      my response to him "bugger off Maunder, i'm busy" ;) Bryce

      MCAD --- To paraphrase Fred Dagg - the views expressed in this post are bloody good ones. --
      Publitor, making Pubmed easy. http://www.sohocode.com/publitor

      Our kids books :The Snot Goblin, and Book 2 - the Snotgoblin and Fluff

      1 Reply Last reply
      0
      • C Christian Graus

        The lines generated by a tool are generally boilerplate, VS does not write code in any meaningful way, it just generates standard lines, like event handlers, when you tell it to. so, you wrote it all.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        B Offline
        B Offline
        Bart
        wrote on last edited by
        #7

        Of course I wrote it all, its just that I couldnt say 50,000 or 150,000..... I dont really think it matters but I just expected some project properties or something to give me a rough estimate. I really had no clue......

        bart

        1 Reply Last reply
        0
        • C Christian Graus

          The lines generated by a tool are generally boilerplate, VS does not write code in any meaningful way, it just generates standard lines, like event handlers, when you tell it to. so, you wrote it all.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #8

          I very rarely write code. Most of it is "generated" by Intellisense. Steps:

          1. Type "using System.T"
          2. Select "System.Threading".
          3. Type a semicolon.

          Generated Code:

          using System.Threading;

          ;P

          Visual Studio is an excellent GUIIDE.

          B 1 Reply Last reply
          0
          • A AspDotNetDev

            I very rarely write code. Most of it is "generated" by Intellisense. Steps:

            1. Type "using System.T"
            2. Select "System.Threading".
            3. Type a semicolon.

            Generated Code:

            using System.Threading;

            ;P

            Visual Studio is an excellent GUIIDE.

            B Offline
            B Offline
            Bart
            wrote on last edited by
            #9

            OK, so how many lines is your current project? I bet you are like me AND YOU DONT KNOW!

            bart

            A C OriginalGriffO A 4 Replies Last reply
            0
            • B Bart

              A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

              bart

              M Offline
              M Offline
              Marc Clifton
              wrote on last edited by
              #10

              Bart wrote:

              How many did you write and how many were generated by a tool?

              Ask him when he stopped beating his wife. Maybe he'll get the point. Marc

              Will work for food. Interacx

              I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

              1 Reply Last reply
              0
              • B Bart

                A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

                bart

                B Offline
                B Offline
                Bart
                wrote on last edited by
                #11

                Hah, found this C#, Visual Basic and C++ .NET Line Count Utility[^]

                bart

                1 Reply Last reply
                0
                • B Bart

                  A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

                  bart

                  M Offline
                  M Offline
                  Member 96
                  wrote on last edited by
                  #12

                  I remember caring about that waaaay back in the day. These days it's pretty irrelevant with all the template generated lines etc. The app I'm working on today has over 20 projects in the solution. Lines of code must be zillions by now. ;)


                  "Creating your own blog is about as easy as creating your own urine, and you're about as likely to find someone else interested in it." -- Lore Sjöberg

                  1 Reply Last reply
                  0
                  • B Bart

                    A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

                    bart

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

                    What's a line of code? I can break a statement onto many lines, and I can put many statements on one line. A C/C++/C# source file may contain no linefeeds at all (only pre-processor directives require them). Counting statements might make some sense, but even that is fairly pointless. Just say "42".

                    1 Reply Last reply
                    0
                    • B Bart

                      A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

                      bart

                      M Offline
                      M Offline
                      Mycroft Holmes
                      wrote on last edited by
                      #14

                      Why should you even care, you will be responsible for it no matter where it comes from. What if you wrote the code generator, does that get special status. Talk about stupid questions! And no I have no idea and could care even less.

                      B 1 Reply Last reply
                      0
                      • M Mycroft Holmes

                        Why should you even care, you will be responsible for it no matter where it comes from. What if you wrote the code generator, does that get special status. Talk about stupid questions! And no I have no idea and could care even less.

                        B Offline
                        B Offline
                        Bart
                        wrote on last edited by
                        #15

                        Hold said horse. He was only a mate and just asked out of curiosity. He was wondering how I understood all that foreign tongue stuff. He is probably a bit like DD's boss. (No, he didnt touch my PC)

                        bart

                        B M 2 Replies Last reply
                        0
                        • B Bart

                          A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

                          bart

                          J Offline
                          J Offline
                          jesarg
                          wrote on last edited by
                          #16

                          You could always write a utility to count semi-colons in all files in a directory to give you a rough estimate.

                          P 1 Reply Last reply
                          0
                          • B Bart

                            OK, so how many lines is your current project? I bet you are like me AND YOU DONT KNOW!

                            bart

                            A Offline
                            A Offline
                            AspDotNetDev
                            wrote on last edited by
                            #17

                            Use a regular expression file search tool to count the number of semicolons in your project, and exclude the files that are designer created. First, copy all the files to a temp directory. Then search that directory for all the designer files; delete those files. Searching for the number of semicolons should then give you a pretty accurate estimate of number of lines. If you want actual lines rather than lines of code, you could use the same regular expression approach to count the number of line endings. Actually, that approach wouldn't work with me. Most of my code is XAML (hand typed, not designer generated), so there are no semicolons to count. An alternative approach would be to decide how many characters an average line takes up (say, 80), then divide the file size by that number to get the approximate number of lines. Might have to use half that number if the text uses one of those "double wide" character encodings.

                            Visual Studio is an excellent GUIIDE.

                            1 Reply Last reply
                            0
                            • B Bart

                              A friend watched me writing code for a project asked: So, how many lines of code is that? How many did you write and how many were generated by a tool? I didnt know..... How can I find out?

                              bart

                              S Offline
                              S Offline
                              Steve Mayfield
                              wrote on last edited by
                              #18

                              Software metrics tools for C/C++ [^]

                              Steve _________________ I C(++) therefore I am

                              1 Reply Last reply
                              0
                              • B Bart

                                Hold said horse. He was only a mate and just asked out of curiosity. He was wondering how I understood all that foreign tongue stuff. He is probably a bit like DD's boss. (No, he didnt touch my PC)

                                bart

                                B Offline
                                B Offline
                                bryce
                                wrote on last edited by
                                #19

                                fair enough - you do have to be careful about what you mate gets to touch *grin* Bryce

                                MCAD --- To paraphrase Fred Dagg - the views expressed in this post are bloody good ones. --
                                Publitor, making Pubmed easy. http://www.sohocode.com/publitor

                                Our kids books :The Snot Goblin, and Book 2 - the Snotgoblin and Fluff

                                1 Reply Last reply
                                0
                                • B Bart

                                  Hold said horse. He was only a mate and just asked out of curiosity. He was wondering how I understood all that foreign tongue stuff. He is probably a bit like DD's boss. (No, he didnt touch my PC)

                                  bart

                                  M Offline
                                  M Offline
                                  Mycroft Holmes
                                  wrote on last edited by
                                  #20

                                  In which case he owes you a beer while you describe what you do, I'm betting you can drag it out for a couple of beer but you are going to have to watch out for that glazed look that come into their eyes.

                                  1 Reply Last reply
                                  0
                                  • B Bart

                                    OK, so how many lines is your current project? I bet you are like me AND YOU DONT KNOW!

                                    bart

                                    C Offline
                                    C Offline
                                    Christian Graus
                                    wrote on last edited by
                                    #21

                                    There are plenty of free VS add ins that generate that number for you.

                                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                    1 Reply Last reply
                                    0
                                    • J jesarg

                                      You could always write a utility to count semi-colons in all files in a directory to give you a rough estimate.

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

                                      int x ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                                      x = 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                      Y A 2 Replies Last reply
                                      0
                                      • P PIEBALDconsult

                                        int x ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                                        x = 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                        Y Offline
                                        Y Offline
                                        Yusuf
                                        wrote on last edited by
                                        #23

                                        it is still 42 :^)

                                        Yusuf May I help you?

                                        1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

                                          int x ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                                          x = 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                                          A Offline
                                          A Offline
                                          AspDotNetDev
                                          wrote on last edited by
                                          #24

                                          I would say semicolon counting is still more accurate for counting lines of code than line endings. And like others have said, counting the number of lines is no measure of quality (the above code being of crap quality, but a large number of lines). Or the two method could be combined into something like this:

                                          int numberOfLines = Regex.Matches(@"\;( |\t)*(\r|\n|\\\\|\\\*)", fileText).Count;

                                          But then some trickster could get you with this:

                                          public void DoIt()
                                          {
                                          int x
                                          = 5; int
                                          y = 10;}

                                          However, if the guy just wants to tell his friend how much code he wrote, this method (or similar approximations) should work fine.

                                          Visual Studio is an excellent GUIIDE.

                                          P 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