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

    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
      • A AspDotNetDev

        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 Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #25

        Does that handle for loops?

        for
        (
        int i = 0 ;
        i < 10 ;
        i++
        )
        {
        ...
        }

        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

          A Offline
          A Offline
          alex barylski
          wrote on last edited by
          #26

          Run a metrics calcuation tool before you write a single line of code. Whenever you generate code automagically using some tool, run it again before and after. Calculate your averages, it's not that hard. Google SLOCCount it's a linux tool that calculates SLOC for many languages, I use t all the time :) Cheers, Alex

          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
            Mark_Wallace
            wrote on last edited by
            #27

            Just reply "I wrote all the good ones, and tool who sits by the window wrote the rest".

            I wanna be a eunuchs developer! Pass me a bread knife!

            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

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

              I don't know; I also don't care. "Lines of code" is a meaningless statistic, and has been since Cobol and Fortran stopped being the standard languages. Is a line with just an "{" or "}" a "line of code"? Or is

                  MySqlCommand cmd = new MySqlCommand("UPDATE " + TableNames.my\_RoleAndPerformance.ToString() +
                                                      " SET role=@R, dateNextChangeRole=@NCR, data=@D, ValidationCode=@VC" +
                                                      " WHERE UserId = @ID");
                  cmd.Parameters.AddWithValue("@R", role);
                  cmd.Parameters.AddWithValue("@NCR", dateNextChange);
                  cmd.Parameters.AddWithValue("@D", data);
                  cmd.Parameters.AddWithValue("@VC", validationCode);
                  cmd.Parameters.AddWithValue("@ID", userId);
              

              One "line of code", since it will not work without the entire sequence? Forget "lines of code", think "functional blocks", think "tested and peer reviewed", think deadlines, bug count, any performance measure that actually means something!

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

              "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
              • 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
                Stuart Dootson
                wrote on last edited by
                #29

                As I program in C++ generally, I'll just use this command at the root of my source tree:

                ack --cpp -c ; | wc -l

                This counts all semi-colons, which is a reasonable approximation for the total lines in the project. I never differentiate between auto-generated/me-generated lines.

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                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

                  C Offline
                  C Offline
                  Chris Quinn
                  wrote on last edited by
                  #30

                  >>> how many were generated by a tool? For some of the people I work with, this is 100%!

                  ==================================== Transvestites - Roberts in Disguise! ====================================

                  1 Reply Last reply
                  0
                  • B Bart

                    Grrrrr...........:mad:

                    bart

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

                    Ooh a puppy. Can we keep him?

                    Join the cool kids - Come fold with us[^]

                    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
                      Anna Jayne Metcalfe
                      wrote on last edited by
                      #32

                      283,000 at the last formal build. I know because we track a variety of project metrics on each build using the (free) SourceMonitor[^] tool. I'm more interested in average cyclomatic complexity has gone down (which is good as it means that the code is getting less crufty) or up (which implies that some of the changes in the build are more complex than they need to be) rather than LOC, but we get that as well.

                      Anna :rose: Having a bad bug day? Tech Blog | Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                      1 Reply Last reply
                      0
                      • A AspDotNetDev

                        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 Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #33

                        Oh, and semi-colons in verbatim strings:

                        string sql =
                        @"
                        SELECT COUNT(*) FROM table1 ;
                        SELECT COUNT(*) FROM table2
                        " ;

                        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