zoukankan      html  css  js  c++  java
  • 系统分析与设计结对项目

    作业成果

    作业源码-java-gitee.

    作业要求

    老师源作业要求
    根据WordCount的需求描述,先编程实现,再编写单元测试,最后撰写博客。

    合作伙伴

        201631062120 201631062220
    

    编码过程

    PSP表格

    ||||||||||||||
    |:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|
    |PSP2.1 |PSP阶段|预估耗时(分钟)|实际耗时(分钟)
    |· Planning | · 计划 | 60 | 50
    |· Estimate | · 估计这个任务需要多少时间 | 20 |20
    |· Development | · 开发 | 330 | 330
    |· Analysis| · 需求分析 (包括学习新技术) | 30 | 30
    |· Design Spec | · 生成设计文档 | 0 | 0
    |· Design Review | · 设计复审 (和同事审核设计文档) |20 |20
    |· Coding | · 代码规范 (为目前的开发制定合适的规范)| 0 | 0
    |· Code Review |· 具体设计 | 20 |20
    |· Test | · 具体编码 | 180| 100
    |· Reporting | · 代码复审 | 20 | 20
    |· Test Report | · 报告 |140|140
    |· Size Measurement | · 测试报告 |60 | 60
    |· Postmortem & Process | · 计算工作量 | 20| 20
    |· Improvement Plan | · 事后总结, 并提出过程改进计划 |60 | 60
    | | · 合计 | 520 | 540

    互审代码

    李欣 TO 王筱哲 :逻辑写的非常不错,唯一不足的是注释有点少,希望以后多写注释

    王筱哲 TO 李欣 :思路很清楚,感觉还不错

    基本功能基本一样,扩展功能主要是分成几个class,都有点困扰,代码不是那么清楚,都有所改动,最后基本一致

    UML类图

    属性方法

    文件对象

    public class Wc {
        public int chars;
        public int words;
        public int lines;
        public int codeLines;		//代码行数
        public int empLines;		//空行数
        public int comLines;        //注释行数
    
        public int getChars() {
            return chars;
        }
    
        public int getWords() {
            return words;
        }
    
        public int getLines() {
            return lines;
        }
    
        public int getCodeLines() {
            return codeLines;
        }
    
        public int getEmpLines() {
            return empLines;
        }
    
        public int getComLines() {
            return comLines;
        }
    }
    

    命令对象

        public static String inputFile;
        public static String outputFile;
        public static boolean needC;
        public static boolean needW;
        public static boolean needL;
        public static boolean needO;
        public static boolean needS;        //输入参数中是否有“-s”
        public static boolean needA;        //输入参数中是否有“-a”
        public static boolean needE;        //输入参数中是否有“-e”
    

    查找代码行、注释行、空行

        此处不同于最终项目,是最初时,对于注释行的检测的初试
    
        public static Count wc(String inputFile) throws IOException {
            boolean isNote = false;
            int notNote=0;
            String lineString = "";
            Count count=new Count(0,0,0,0,0,0);
            String txt = "";
            String[] buffer = null;
            String[] buffer2;
            File dir=new File(inputFile);
            BufferedReader bf = new BufferedReader(new FileReader(dir));
           while((txt=bf.readLine())!=null){
                buffer2=txt.split(",| |	|
    ");
                for(int i=0;i<buffer2.length;i++){
                    if(!buffer2[i].equals(""))
                        count.WordCount++;
                }
                count.LineCount++;
                count.CharCount+=txt.length();
            }
            while((lineString=bf.readLine())!=null){
    
                //遇到 , 空格 就结束赋值
                /*buffer=lineString.split(",| ");
                for(int i=0;i<buffer.length;i++){
                        if(!buffer[i].equals("")){
                            count.WordCount++;
                        }
                }*/
                lineString=lineString.trim();
                //空行,一个字符的也算空行
                if (lineString.matches("^[//s&&[^//n]]*$")||lineString.length()==1) {
                    count.EmptyCount++;
                }
                //注释/*的开始
                else if (lineString.startsWith("/*") && !lineString.endsWith("*/")||((lineString.startsWith("{/*")
                        ||lineString.startsWith("}/*"))&&!lineString.endsWith("*/"))){
                    count.NoteCount++;
                    isNote=true;
                }
                //没有遇到*/
                else if(isNote&&!lineString.endsWith("*/")&&!lineString.startsWith("*/")) {
                    notNote++;
                    count.NoteCount++;
                }
                //遇到*/
                else if (isNote == true && (lineString.endsWith("*/")||lineString.startsWith("*/"))) {
                    count.NoteCount++;
                    isNote=false;
                }
                //注释行
                else if (lineString.startsWith("//")|| lineString.startsWith("}//")||lineString.startsWith("{//")||
                        ((lineString.startsWith("{/*") ||lineString.startsWith("}/*")||lineString.startsWith("/*"))
                                && lineString.endsWith("*/"))) {
                    count.NoteCount++;
                }
                else{
                    count.CodeCount++;
                }
            }
            bf.close();
            count.NoteCount-=notNote;
            count.CodeCount+=notNote;
    
            return count;
        }
    

    测试

        命令
        wc.exe -l -c -w -a D:\Desktop\123.c"
        结果
        123.c, 字符数: 44
        123.c, 单词数: 30
        123.c, 行数: 7
        123.c, 代码行/空行/注释行: 2/4/1
    

    总结

        停用词表的检测存在些许问题,没有达到预期效果。因为时间有限,高级功能最终也没有真正实现。希望后续时间可以完成
        另外结对编程相比自己编程来说,可以更好的讨论和研究需求和具体实现,但是也存在双方意见不同、争执的时候。但总体来说,1+1>2,遇到问题时,有人可以商量,比一个人思索更有效些。
  • 相关阅读:
    linux内核中创建线程方法
    高等数学所有符号的写法与读法
    Git学习笔记03--git reset
    git status message
    [小技巧] git: Your branch and 'origin/master' have diverged
    phalcon: 资源文件管 理 引入css,js
    phalcon: model 验证数据完整性
    phalcon:model 事件与事件管理器
    phalcon: 查找记录(Finding Records)可用的查询设置如下:
    phalcon count统计
  • 原文地址:https://www.cnblogs.com/Myemperor/p/9799853.html
Copyright © 2011-2022 走看看