When counting lines in code are the comments counted?

_vk_vk
edited October 2014 in General Discussion

When I read "it's over 3000 lines of code", does this includes comments and skipped lines?

Comments

  • "it's over 3000 lines of code"

    Depends on the author but I suspect it will include everything because it is easy to look at the last line number in the editor and more lines sounds good ;)

    I wouldn't discount the importance of comments as they help make the code maintainable, or whitespace (empty lines and tabs) as they help make the code readable.

  • thanks quark.

  • Most likely it won't, Because the comments are for the person, so they won't really count as a contributing part of the code, but like quark said some people can say they are.

  • edited October 2014

    Yes, they include everything, from package declaration to imports and comments and lines with only braces.

    As said, these figures are probably computed using the wc Unix command or similar, so not distinguishing "real code" from less "significant" lines.

    Beside, writing a good JavaDoc, for example, is as much work as writing code, so there is no reason not to include it in the figure.

  • Like Phil and quark said: yep, I've always seen comments counted. If TechWiz can show us specific examples of comments not being counted, I'd be interested in seeing them.

    This is one of the many many many reasons that using lines of code as a code metric is a pretty horrible idea. So I would be pretty skeptical of anything that follows a statement like that.

  • Thanks you all! :)

  • edited October 2014

    "using lines of code as a code metric is a pretty horrible idea"
    I agree, and most people today agree too. If a manager insists in measuring your productivity by the number of lines of code you can produce daily (I hope the concept is obsolete now), you end up writing 3 statements where you would write only one, putting each intermediary step in a local variable...

    "I would be pretty skeptical of anything that follows a statement like that"
    Still, it can be a general useful measure the amplitude of a project, coarsely grained. A project with 300,000 lines of code is a bit more ambitious, perhaps, than one with 3,000.
    Although it doesn't reflect code quality, project interest, and so on...

    Of course, it also depends on the language: Java is verbose, you have lot of boilerplate code with no real value to the logic (getters, setters, verbose declarations), while modern languages like Dart or Ceylon are terser (implicit accessors), Python avoids lines with blocks {} and APL is one of the tersest (and more cryptic) languages. Not to mention languages made specially for code golf...

  • edited October 2014

    I agree with KevinWorkman / PhiLho, determining complexity by the number of lines of code is ridiculous. If this really were a used as a metric then programmers would expand their code by adding white space or having multiple lines of code where fewer would still calculate the same result

    That being said, chances are that the programmer(s) responsible for the 3000+ lines of code did not do that. Personally I would determine the complexity by the amount of code required to coordinate concepts. If the programmer(s) isolate different concepts with classes or functions (hopefully the do) then you would have to understand each concept and then the complexity would be the amount of code to make them work together

  • _vk_vk
    edited October 2014

    Thanks for all thoughts. Are there guidelines/hints on how to make comments on code? I mean, as much as I try to be organized and neat, I always find other's people code more clean and easy to read then mine. I keep trying some "ASCII art" :) to spread the blocks apart, and all, but not satisfied with the results…

    /**
    /**********************************************************************/
    /**********************************************************************/
    /******************  HOW TO BE CLEAN AND NEAT?  ***********************/
    /**********************************************************************/
    /**********************************************************************/
    

    :)

  • There are several types of comment

    1) comments to be used by document generators e.g. javadoc, Doxygen to produce API reference so others can interface/use your software.

    2) source code comments which give specific information about the source code implementation. These are generally for programmers wanting to maintain or extend the software.

    3) simply to be informative e.g. licence information.

    Anything else, including ASCII art is probably a waste of effort, but that is just my opinion so feel free to ignore it. :)

Sign In or Register to comment.