【代码复审结果】


  • 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. Python基础知识:模块

    目录 JSON模块&pickle模块 requests模块 time模块 datetime模块 logging模块 os模块 sys模块 hashlib模块 re模块.正则表达式 config ...

  2. SQL取最大值编码(自动编码)

    SQL取最大值编码(自动编码) 用途 : 使用SQL语法做出自动编码效果,例如将单号自动+1后,产生该笔单号 Table说明 SQL语法 SELECT 'A'+REPLICATE('0',7-len( ...

  3. 09LaTeX学习系列之---Latex 字体的设置

    目录 目录: (一) 字体族的设置 1.说明: 2.源代码: 3.输出结果: (二) 字体系列的设置 1.源代码: 2.输出效果: (三) 字体形状的设置 1.源代码: 2.输出效果: (四) 字体大 ...

  4. SAP CRM 忠诚度相关表的关系图

    这是一张有关会员,积分,活动等内容的相关表的关系图,对相关的开发工作会有帮助. 原文标题:Table schema for managing customer loyality 本文链接:http:/ ...

  5. ConcurrentLinkedQueue源码解读

    1.简介 ConcurrentLinkedQueue是JUC中的基于链表的无锁队列实现.本文将解读其源码实现. 2. 论文 ConcurrentLinkedQueue的实现是以Maged M. Mic ...

  6. Scrapy运行流程

    接下来的图表展现了Scrapy的架构,包括组件及在系统中发生的数据流的概览(绿色箭头所示). 下面对每个组件都做了简单介绍,并给出了详细内容的链接.数据流如下所描述. 来源于https://scrap ...

  7. HDU3949 XOR

    嘟嘟嘟 集训的时候发现自己不会线性基,就打算学一下. 这东西学了挺长时间,其实不是因为难,而是天天上午考试,下午讲题,结果晚上就开始颓了. 今天总算是有大块的时间好好学了一遍. 这里推荐menci大佬 ...

  8. C中指针符*和取址符&

    学习了C语言之后,关于指针部分看了无数遍,有时候明明觉得自己看懂了,指针就是地址,但是总是在看代码时候糊里糊涂的搞不明白,最近又关于指针强化了一把. 大部分情况下对于程序中指针糊涂是因为不明白指针符“ ...

  9. Lodop 打印控件

    1.下载 2.使用 一 下载安装控件 官网下载地址:http://www.lodop.net/download.html 参考:http://www.c-lodop.com/demolist/Prin ...

  10. 洛谷 P2256 一中校运会之百米跑

    题目链接 https://www.luogu.org/problemnew/show/P2256 题目背景 在一大堆秀恩爱的**之中,来不及秀恩爱的苏大学神踏着坚定(?)的步伐走向了100米跑的起点. ...