6 ms·
Count the effective number of lines of code of a project
- tkellogg 15y agoIt's one of those things where you get excited that there's something so accurate, but also a little fearful of how management could use it to incent badly written code.
- DougWebb 15y agoThat depends on the management. There can be an incentive for comment/code ratio, with tooling to extract and measure metrics on the comments to make sure they're not trivial. Another possible incentive would be based on metrics of diffs, using a ratio of features added or bugs fixed against the number of lines added, where a smaller number of lines is better.
- benjiweber 15y agoWhy would you incentivise comments over self documenting code that clearly expresses the intent? Comments get out of date and aren't subject to static analysis. There are plenty of techniques that let you write code that reads like an English specification rather than details of how it is implemented. If you find yourself needing to write a comment, it's always good to think how you could re-write the code to say the same thing as the comment.
- DougWebb 15y agoI see self-documenting code as another type of comment, not a replacement. The comments describe what the code is supposed to be doing, what business problem it addresses, etc, while the code documents how the code does what it does. Your comments shouldn't get out of date unless the purpose of the code changes. If it's just the implementation that changes, the comments should still apply.
- bunderbunder 15y agoIn my experience, the density of comments is inversely proportional to the extent to which they help the reader to understand how the code works. On my current project, it also tends to be inversely proportional to maintainability. Never send slashes and asterisks to do a function declaration's job.
- DougWebb 15y agoYour problem is poor comments, not too many comments.
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- Feanim 15y ago% cloc linux-3.2.1 37595 text files. 37127 unique files. 3995 files ignored. http://cloc.sourceforge.net v 1.53 T=355.0 s (93.8 files/s, 39819.0 lines/s) -------------------------------------------------------------------------------- Language files blank comment code -------------------------------------------------------------------------------- C 16577 1555942 1573561 8036765 C/C++ Header 13614 316003 537441 1648074 Assembly 1252 41013 52412 252626 XML 142 2881 739 40365 make 1509 6296 6821 23851 Perl 41 3268 2592 15131 Bourne Shell 67 685 1552 3885 yacc 5 455 323 2979 Python 19 561 269 2605 C++ 1 208 57 1524 lex 5 204 237 1328 awk 8 90 79 714 Bourne Again Shell 30 75 56 450 HTML 2 58 0 378 NAnt scripts 1 93 0 372 Lisp 1 63 0 218 ASP 1 33 0 137 m4 1 15 1 84 XSLT 6 13 27 70 sed 1 0 3 30 vim script 1 3 12 27 Teamcenter def 1 0 2 5 -------------------------------------------------------------------------------- SUM: 33285 1927959 2176184 10031618 --------------------------------------------------------------------------------
- deleted 15y ago[deleted]