计算行数 [英] To count the line of code

查看:98
本文介绍了计算行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何工具可以帮助计算解决方案的长度(带空行和无空行).我的解决方案非常大,现在客户需要知道到目前为止完成的代码行.因此,如果您知道任何此类工具,请提供帮助.

Is there any tool that can help to count the length of my solution, with blank lines and without blank lines. My solution is very large, now the client need to know the line of code done so far. So in case if you know any such tool please help.

推荐答案

请看这篇出色的文章:
Take a look at this great article : Line Counter - Writing a Visual Studio 2005 & 2008 Add-In


为什么?代码行是一个非常没用的指标-是否值得计算一个块的开始:
Why? Lines of code is a pretty useless metric - is it worth counting a block start:
if (condition)
   {
   variable = value;
   }

那是一行代码吗?还是两个?还是四个?注释是否值得-应该这样做,因为它们是对软件未来可维护性的投资.否则他们不应该这样做,因为它们不会为用户体验"添加任何内容.

如果必须的话,编写自己的代码非常简单:使用File.ReadAllLines以一行一行的形式返回内容,然后丢弃空白行.遍历您的解决方案文件夹,您就在那里.
大概一个半小时就可以编写和测试.此外,您可以将自己的指标应用于上述问题.

Is that one line of code? Or two? Or four? Do comments count - they should do, because they are an investment in the future maintainability of the software. Or they shouldn''t, because they don''t add anything to the "user experience".

If you must, then it is pretty simple to write your own: Use File.ReadAllLines to return the content in line by line form, and then discard blank lines. Recurse through your solution folder, and you are there.
About half an hour to write and test, at a guess. In addition, you can apply your own metrics to the questions above.


您好,
到目前为止,可以通过编写5/6行代码来完成,步骤如下所示:
(i)读取源文件并存储到字符串类型的变量中.
(ii)使用"NewLinee()"将其拆分为arrayList.
(iii)编写一个foreach循环以对行进行计数.

我想就是这样.
Hi,
This could be done by writing 5/6 line of code so far, the steps are listed below:
(i) Read the source file & store into a string type variable.
(ii) Split it with ""NewLinee()" in to arrayList.
(iii) Write a foreach loop to count lines.

I think that''s it.


这篇关于计算行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆