【个人博客作业II】代码复审结果
【代码复审结果】
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)
- Are all data inputs checked (for the correct type, length, format, and range) and encoded?
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’?
- Do comments exist and describe the intent of the code?
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】代码复审结果的更多相关文章
- [2017BUAA软工]第二次博客作业:代码复审
〇.comment链接 https://github.com/hanayashiki/Sudoku/issues/1 一.代码复审 1.概要部分 (1)代码能符合需求和规格说明么? 经测试,对于合法输 ...
- 个人博客作业week2——代码复审
1.代码规范 这些规范都是官僚制度下产生的浪费大家的编程时间.影响人们开发效率, 浪费时间的东西. 代码规范并不是从官僚制度下产生,它是为了提高项目团队开发效率而产生的一种工具,能够极大的增强代码可读 ...
- 个人博客作业-Week2 (代码规范, 代码复审)
代码规范: 1.这些规范都是官僚制度下产生的浪费大家的编程时间.影响人们开发效率, 浪费时间的东西. 编码规范它包含了代码格式,还包括了编码风格和其他规范,通常涉及:缩进.空格使用.Tab使用 注释. ...
- 【个人博客作业II】有关代码规范问题的讨论
参考课程辅导书<构建之法>可以知道,程序的代码规范常指代码风格规范和代码设计规范两个方面,其中:代码风格规范包括(缩进,行宽,括号,断行与空白行,分行,命名,下划线,大小写,注释这几个部分 ...
- OO第三次博客作业---透过代码看设计
不得不说的JSF 经过前几次作业的煎熬.出租车的代码量不断地增多.而出租车问题在不断的完善,这也就牵涉到一个问题,那就是最初出租车程序的设计问题,如果一开始设计的就有问题的话,那么在后来的过程中就会遇 ...
- 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 ...
- C语言l博客作业05
问题 回答 这个作业属于哪个课程 C语言程序设计ll 这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/SE2019-2/homework/9830 我在这 ...
- C语言博客作业08
C语言I博客作业08](https://www.cnblogs.com/490-85-00-58-/p/11863312.html) 问题 回答 这个作业属于那个课程 C语言程序设计II 这个作业要求 ...
- c语言1博客作业08
一.本周作业头 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 http://edu.cnblogs.com/campus/zswxy/SE2019-3/homework/9982 我在 ...
随机推荐
- js入门-文本框输入特定内容控制另一个文本框
在填写表单时,有时需要某些文本框隐藏,当一文本框输入特定内容时才会显示隐藏的文本框,这一功能可以用onchange事件或oninput事件实现.下面对比下两种方法实现的区别: onchange()定义 ...
- 【PAT】B1041 考试座位号(15 分)
/* */ #include<stdio.h> #include<algorithm> using namespace std; struct stu{ char number ...
- tkinter学习系列之(六)Radiobutton控件
目录 目录 前言 (一)基本属性 (二)在Frame里布局: 目录 前言 Radiobutton单选框,在一组选框中,只能选中一个. (一)基本属性 (1)特有属性: value 按钮的值 varia ...
- Hadoop2.7.6_02_HDFS常用操作
1. HDFS常用操作 1.1. 查询 1.1.1. 浏览器查询 1.1.2. 命令行查询 [yun@mini04 bin]$ hadoop fs -ls / 1.2. 上传文件 [yun@mini ...
- Web服务器的反向代理nginx
nginx作为web服务器一个重要的功能就是反向代理. Nginx配置详解 序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭 ...
- centos7升级内核版本
本文转载http://blog.csdn.net/nciasd/article/details/51490146,大神非常厉害!!!!! 查看当前系统的内核版本 # uname -r 1.导入key ...
- 1873 初中的算术(java大数)
1873 初中的算术 1 秒 131,072 KB 10 分 2 级题 Noder现在上初三了,正在开始复习中考.他每天要计算型如 (a× a× a× ⋯× a) ...
- Jessica's Reading Problem POJ - 3320(尺取法2)
题意:n页书,然后n个数表示各个知识点ai,然后,输出最小覆盖的页数. #include<iostream> #include<cstdio> #include<set& ...
- day02---编程语言、python解释器以及变量
计算机编程语言分类: 机器语言 直接用计算机能理解的二进制指令编写程序,来直接控制硬件.(用机器语言编写的程序称为目标程序) 优点:执行效率高,属于计算机最底层语言 缺点:开发效率低.跨平台性差 汇编 ...
- 市场不相信眼泪:AI第一股暴力裁员 惨了
近日,有网友在社交平台匿名爆料称,科大讯飞准备优化30%的正式员工. 还有人匿名爆料,科大讯飞无补助报销出差加班,迫使员工离职,并将矛头指向了一个叫“黄狗子”“黄国庆”的角色. 有媒体猜测,科大讯飞采 ...