【代码复审结果】


  • General

    • Does the code work? Does it perform its intended function, the logic is correct etc.

      • 基本完成个人任务需求;
      • 未实现功能:带分数生成,括号支持不完善(无(1+5)×(3-5)这种,也有7/9/2*8这样存在二义性的情况出现),除零/负数的规避处理,规范化输出(N. 运算式);
      • 逻辑基本正确,有较为完善的异常处理机制;
    • Is all the code easily understood?

      • 较为易读,有较为完整的注释,命名直截了当,用规范化的接口说明;
    • Does it conform to your agreed coding conventions? These will usually cover location of braces, variable and function names, line length, indentations, formatting, and comments.
      • 因为使用的语言不一代码风格差异较大,括号换行处理方式不一(左括号不换行),其他基本一致;
    • Is there any redundant or duplicate code?
      • Equation.cpp里的solve函数没有用到,最后用的是重写的solve1;
    • Is the code as modular as possible?
      • 模块化程度较高,分数,表达式,IO处理各成一模块,分数和表达式集成到类里,分工细致;
      •  void fff();
        void exitErr(char* info, int errNum);
        void work1(int,int);
        void work2(char*, char*);
        int isp(char);
        int icp(char); class Fraction{
        public:
        Fraction();
        Fraction(int, int);
        int static gcd(int, int);
        Fraction operator+(const Fraction &);
        Fraction operator-(const Fraction &);
        Fraction operator*(const Fraction &);
        Fraction operator/(const Fraction &);
        Fraction operator=(const Fraction &);
        bool operator==(const Fraction &);
        int numerator;
        int denominator;
        string toString();
        }; class Equation{
        public:
        Equation();
        Equation(int); //构造,输入maxNum
        string getLeft(); //返回左边式子
        string getRight(); //返回右边式子 用于输出
        bool equals(Equation &); //用于判重 static int solve(char*);
        static Fraction solve1(string); private:
        int leftSum; //用于算式判重
        Fraction rightSum; //用于算式判重
        string rightStr;
        string leftStr; //char* solveDiv(char*);
        }; #endif
    • Can any global variables be replaced?

      • 仅用了宏函数,无全局变量;
      • #define random(max) (rand()%(max))
    • Is there any commented out code?
      • 有注释掉的代码;
    • Do loops have a set length and correct termination conditions?
      • 均有设置,不过也存在较为繁冗的判断条件,如Equaltion::solve1中的 while (signTop != 0 && icp(str[i])<=isp(signStack[signTop - 1]) && !RMeetL)//这里检查符号栈是否为空,且判断符号优先级顺序,并检查左右符号是否已经完成匹配,不过其实只需要判断栈空即可进入循环,对于括号匹配和优先级顺序判断可以嵌入到if else语句分支中,相应设置break即可;
      •  int isp(char c){
        switch (c)
        {
        case '#':
        return ;
        break;
        case '^':
        return ;
        break;
        case '*':case '/': case '%':
        return ;
        break;
        case '+':case '-':
        return ;
        break;
        case '(':
        return ;
        break;
        case ')':
        return ;
        break;
        default:
        exitErr("Error in isp", -);
        return -;
        break;
        }
        }
    • Can any of the code be replaced with library functions?
      • 没有可用库函数替代的函数
    • Can any logging or debugging code be removed?
      • 无相关代码

  • Security

    • Are all data inputs checked (for the correct type, length, format, and range) and encoded?

      • 执行批改功能时文件需规范化文件格式,命令行参数输入检查比较完善(三次检查)

         if (strlen(argv[i]) != ) exitErr("command valid", -);
        tmpchar = argv[i][];
        cmdchar = argv[i][];
        if (tmpchar != '-' || (cmdchar != 'n'&&cmdchar != 'r'&&cmdchar != 'e'&&cmdchar != 'a'))exitErr("command valid", -);
        i++;
        if (i == argc) exitErr("command valid", -);
    • Where third-party utilities are used, are returning errors being caught?
      • 未使用第三方程序
    • Are output values checked and encoded?
      • 有较全面的异常分析和相应的错误码输出,并写有专门的错误处理函数:
      • void exitErr(char* info, int errNum){
        printf("%s; error code:%d", info, errNum);
        exit(errNum);
        }
         case '(':  //当前进栈只可能是 ) # 才会把 ( 出栈
        //左括号出栈没有计算操作,不需要执行后面的数字、字符入栈与出栈操作,所以continue跳过
        //直接continue会将后面的signTop--出栈操作跳过,造成死循环
        //需要在此将字符'('出栈
        //和上面不同的是,当前字符str[i]不需要入栈
        if (str[i] == ')'){
        signTop--;
        RMeetL = true;
        }
        else{
        exitErr("左括号后没有右括号", -);
        }
        break;
    • Are invalid parameter values handled?
      • 由专门的错误处理函数void exitErr(char* info, int errNum)

  • Documentation

    • Do comments exist and describe the intent of the code?

      • 有较为简洁的Readme文档
    • Are all functions commented?

      • 暂无,下同
    • Is any unusual behavior or edge-case handling described?
    • Is the use and function of third-party libraries documented?
    • Are data structures and units of measurement explained?
    • Is there any incomplete code? If so, should it be removed or flagged with a suitable marker like ‘TODO’?

  • Testing

    • Is the code testable? i.e. don’t add too many or hide dependencies, unable to initialize objects, test frameworks can use methods etc.

      • 可以测试,无过多依赖对象,大部分在函数内部已经完成相应初始化操作
    • Do tests exist and are they comprehensive? i.e. has at least your agreed on code coverage.
      • 无测试单元,下同
    • Do unit tests actually test that the code is performing the intended functionality?
    • Are arrays checked for ‘out-of-bound’ errors?
    • Could any test code be replaced with the use of an existing API?

  • Summary

    • 程序代码较为规范,设计思路清晰,模块化程度高,可读性强,有详细的注释,在输入输出等安全处理方面有仔细考虑过,并限制了较为严格的条件来避免复杂的错误情况,唯一不足就是功能还有待完善,因为除零异常检查尚不完善致使程序测试存在一定的难度,有待进一步改进

【个人博客作业II】代码复审结果的更多相关文章

  1. [2017BUAA软工]第二次博客作业:代码复审

    〇.comment链接 https://github.com/hanayashiki/Sudoku/issues/1 一.代码复审 1.概要部分 (1)代码能符合需求和规格说明么? 经测试,对于合法输 ...

  2. 个人博客作业week2——代码复审

    1.代码规范 这些规范都是官僚制度下产生的浪费大家的编程时间.影响人们开发效率, 浪费时间的东西. 代码规范并不是从官僚制度下产生,它是为了提高项目团队开发效率而产生的一种工具,能够极大的增强代码可读 ...

  3. 个人博客作业-Week2 (代码规范, 代码复审)

    代码规范: 1.这些规范都是官僚制度下产生的浪费大家的编程时间.影响人们开发效率, 浪费时间的东西. 编码规范它包含了代码格式,还包括了编码风格和其他规范,通常涉及:缩进.空格使用.Tab使用 注释. ...

  4. 【个人博客作业II】有关代码规范问题的讨论

    参考课程辅导书<构建之法>可以知道,程序的代码规范常指代码风格规范和代码设计规范两个方面,其中:代码风格规范包括(缩进,行宽,括号,断行与空白行,分行,命名,下划线,大小写,注释这几个部分 ...

  5. OO第三次博客作业---透过代码看设计

    不得不说的JSF 经过前几次作业的煎熬.出租车的代码量不断地增多.而出租车问题在不断的完善,这也就牵涉到一个问题,那就是最初出租车程序的设计问题,如果一开始设计的就有问题的话,那么在后来的过程中就会遇 ...

  6. C语言第七次博客作业--一二维数组

    一.PTA实验作业 题目1:找鞍点 1. 本题PTA提交列表 2. 设计思路 定义n,i,j,ii,jj,a[7][7],flag,max 输入n for i=0 to i=n for j=0 to ...

  7. C语言l博客作业05

    问题 回答 这个作业属于哪个课程 C语言程序设计ll 这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/SE2019-2/homework/9830 我在这 ...

  8. C语言博客作业08

    C语言I博客作业08](https://www.cnblogs.com/490-85-00-58-/p/11863312.html) 问题 回答 这个作业属于那个课程 C语言程序设计II 这个作业要求 ...

  9. c语言1博客作业08

    一.本周作业头 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 http://edu.cnblogs.com/campus/zswxy/SE2019-3/homework/9982 我在 ...

随机推荐

  1. 3.2Python数据处理篇之Numpy系列(二)--- ndarray数组的创建与变换

    目录 (一)ndarray数组的创建 1.从列表以元组中创建: 2.使用函数创建: (二)ndarray数组的变换 1.维度的变换: 2.类型的变换: 目录: 1.ndarray数组的创建 2.nda ...

  2. ccf--20151203--画图

    本题思路如下: 题目和代码如下: 问题描述 试题编号: 201512-3 试题名称: 画图 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 用 ASCII 字符来画图是一件有趣 ...

  3. Sudoku 个人项目1

    Github项目地址:Github 项目相关要求 随机构造出N个不重复的已解答的数独棋盘(0 < N <= 1000000) 在生成数独矩阵时,左上角的第一个数为:(学号后两位相加)% 9 ...

  4. Tomcat 访问页面或服务器异常,请检查这些方面

    若还没有部署网站,请检查 防火墙是否关闭 数据库服务是否打开 浏览器访问的地址和端口是否正确 tomcat 配置文件中的端口是否发生冲突,换一个试试 若出现的是"拒绝连接",检查阿 ...

  5. 写给spring版本的那些事儿

    1.远程调用rmi协议 Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling re ...

  6. Luogu P4727-- 【HNOI2009】图的同构记数

    Description 求两两互不同构的含n个点的简单图有多少种. 简单图是关联一对顶点的无向边不多于一条的不含自环的图. a图与b图被认为是同构的是指a图的顶点经过一定的重新标号以后,a图的顶点集和 ...

  7. mysql之4;

    1表之间的关系: 2select查询语句: 1表之间的关系 (1)多对一:(一个表里的多条记录对应另一个表里的一个记录) 建立多对一的关系需要注意1 先建立被关联的表,被关联的字段必须保证是唯一的2 ...

  8. Hue添加Spark notebook

    参考自https://blogs.msdn.microsoft.com/pliu/2016/06/18/run-hue-spark-notebook-on-cloudera/ 说明 使用Clouder ...

  9. mysql 中sql的执行顺序

    文章转自 https://www.cnblogs.com/annsshadow/p/5037667.html https://www.cnblogs.com/yyjie/p/7788428.html ...

  10. 项目Alpha冲刺 3

    作业描述 课程: 软件工程1916|W(福州大学) 作业要求: 项目Alpha冲刺(团队) 团队名称: 火鸡堂 作业目标: 介绍第三天冲刺的项目进展.问题困难和心得体会 1.团队信息 队名:火鸡堂 队 ...