首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java面试 >

程序员的代码量是怎么计算的?

2012-05-03 
程序员的代码量是如何计算的???经常看到有些网友提起程序员的代码量的问题,代码量怎么算呢?不能说我整天写

程序员的代码量是如何计算的???
经常看到有些网友提起程序员的代码量的问题,代码量怎么算呢?不能说我整天写System.out.println();写100,10000行就说我的代码量是100,10000了吧?什么样的代码才能算呢?

[解决办法]

Java code
import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;public class Files {    static long whiteLine = 0;    static long comentLine = 0;    static long sormaLine = 0;        public static void main(String[] args) {        File f = new File("填写路径,不用具体到文件名,只要路径下有.java文件就可以");        File[] codeFiles = f.listFiles();        for(File child:codeFiles){            //System.out.println(child);            preas(child);        }        System.out.println("空行:"+whiteLine);        System.out.println("注释行:"+comentLine);        System.out.println("有效行:"+sormaLine);    }        private static void preas(File f){        BufferedReader br = null;        Boolean comPd = false;        try {            br = new BufferedReader(new FileReader(f));            String readLine = null;            while((readLine = br.readLine())!=null){                readLine = readLine.trim();                if(readLine.matches("^[\\s&&[^\\n]]*$")){                    whiteLine ++;                }else if(readLine.startsWith("/*")&&!readLine.endsWith("*/")){                    comentLine ++;                    comPd = true;                }else if(readLine.startsWith("/*")&&!readLine.endsWith("*/")){                    comentLine ++;                }else if(comPd){                    comentLine ++;                    if(readLine.endsWith("*/")){                        comPd = false;                    }                }else if(readLine.startsWith("//")){                    comentLine ++;                }else{                    sormaLine++;                }            }        } catch (FileNotFoundException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (IOException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }    }}
[解决办法]
一般公司都是直接给你任务 你做好就行 没人管你代码量
比较正规的公司 会有SVN服务器 你们的代码都放到上面 各个员工每天的代码量一目了然
[解决办法]
代码量不好计算的啊
因为你写的有效代码和无效代码不容易用程序来区分,但是这个计算的时候你又不可能让人去一点一点的看
所以代码量计算其实是一点意思都没有的

热点排行