1. Introduction to the topic
This time, my teammate (Li Zhuoru) chose the topic as the first topic, and my role in this assignment was the navigator.
1. Subject:
When we first started the class, we introduced an example of an automatic generation program of four arithmetic operations in elementary school. Please implement it and require:
- Can automatically generate four arithmetic practice questions
- The number of questions can be customized
- User can choose operator
- The maximum number set by the user (such as within ten, within one hundred, etc.)
- The user chooses whether there are parentheses and whether there are decimals
- The user selects the output method (such as output to a file, printer, etc.)
- It is best to provide a graphical user interface (choose according to your own ability, mainly to complete the above functions)
2. Demand analysis
We are not unfamiliar with the questions. Maybe we have given such exercises to our children. Sometimes teachers will leave such homework for parents at school, so that parents can give their children how many mixed arithmetic questions. Because the questions are manually created , if the volume is large, it is very troublesome to write, and there is no guarantee that there will be repeated topics. Through the automatic generation of four arithmetic problems written, the problems can be quickly and repeatedly generated, which is very practical.
2. Code
1. Code address
2. Screenshot of the test code part
3. Running graphical interface
3. Code Review Form
java code review checklist
importance |
activation |
level |
Check items |
total |
|||
name |
|||
important |
AND | 20 |
Are the naming conventions consistent with the adopted specification? |
AND | 20 |
Did you follow the principle of least length, most information? |
|
important |
N | 50 |
Do has/can/is prefixed functions return boolean? |
Notes |
|||
important |
AND | 10 |
Are the annotations clear and necessary? |
important |
AND | 10 |
Has the complex branching process been annotated? |
AND | 10 |
Is the farther } already annotated? |
|
N | 10 |
Are non-generic variables all commented out? |
|
important |
AND | 50 |
Does the function already have documentation comments? (function, input, return and other optional) |
AND | 10 |
Are special usages commented? |
|
declaration, whitespace, indentation |
|||
AND | 20 |
Is there only one variable declared per line? (especially those types that can go wrong) |
|
important |
AND | 40 |
Has the variable been initialized at the time of definition? |
important |
AND | 40 |
Are the class properties all initialized? |
AND | 20 |
Are code paragraphs properly separated by blank lines? |
|
AND | 20 |
Are spaces being used sensibly to make the program clearer? |
|
AND | 20 |
Is the line of code length within the requirements? |
|
AND | 20 |
Is the line break appropriate? |
|
Statement / Function Distribution / Scale |
|||
AND | 20 |
Are {} containing compound statements paired and conforming to the specification? |
|
N | 20 |
Did you add {} to a single loop, conditional statement ? |
|
AND | 20 |
Is the format of the if/if-else/if-else if-else/do-while/switch-case statement conforming to the specification? |
|
N | 40 |
Does a single variable serve a single purpose? |
|
important |
N | 20 |
Does a single line have only a single function? (do not use; do a multiline merge) |
important |
AND | 40 |
Does a single function perform a single function and match its name? |
AND | 20 |
Are the operators ++ and -- operators compound specification ? |
|
scale |
|||
important |
N | 20 |
A single function does not exceed the specified number of lines? |
important |
N | 100 |
Is the number of indentation levels not exceeded? |
important |
N | 100 |
Have all warnings been eliminated? |
important |
AND | 40 |
Are constant variables declared final ? |
important |
N | 80 |
Is the object checked before it is used? |
important |
N | 80 |
Are local object variables reset to NULL after use ? |
important |
AND | 70 |
Is the access to the array safe? (The valid index value is [0, MAX_SIZE-1] ). |
important |
AND | 20 |
Are you sure that there is no local duplicate definition of variables with the same name ? |
AND | 20 |
Are only simple expressions used in the program? |
|
important |
AND | 20 |
Has operator precedence been made explicit with ()? |
important |
AND | 20 |
Are all judgments in the form of (constant == variable)? |
AND | 80 |
Has process suspension been eliminated? |
|
important |
AND | 80 |
是否每个if-else if-else语句都有最后一个else以确保处理了全集? |
重要 |
无该语句 | 80 |
是否每个switch-case语句都有最后一个default以确保处理了全集? |
N | 80 |
for循环是否都使用了包含下限不包含上限的形式?(k=0; k<MAX) |
|
重要 |
N | 40 |
XML标记书写是否完整,字符串的拼写是否正确? |
无该语句 | 40 |
对于流操作代码的异常捕获是否有finally操作以关闭流对象? |
|
N | 20 |
退出代码段时是否对临时对象做了释放处理? |
|
重要 |
Y | 40 |
对浮点数值的相等判断是否是恰当的?(严禁使用==直接判断) |
可靠性(函数) |
|||
重要 |
N | 60 |
入口对象是否都被进行了判断不为空? |
重要 |
Y | 60 |
入口数据的合法范围是否都被进行了判断?(尤其是数组) |
重要 |
Y | 20 |
是否对有异常抛出的方法都执行了try...catch保护? |
重要 |
Y | 80 |
是否函数的所有分支都有返回值? |
重要 |
Y | 50 |
int的返回值是否合理?(负值为失败,非负值成功) |
N | 20 |
对于反复进行了int返回值判断是否定义了函数来处理? |
|
Y | 60 |
关键代码是否做了捕获异常处理? |
|
重要 |
N | 60 |
是否确保函数返回CORBA对象的任何一个属性都不能为null? |
重要 |
N | 60 |
是否对方法返回值对象做了null检查,该返回值定义时是否被初始化? |
重要 |
N | 60 |
是否对同步对象的遍历访问做了代码同步? |
重要 |
N | 80 |
是否确认在对Map对象使用迭代遍历过程中没有做增减元素操作? |
重要 |
Y | 60 |
线程处理函数循环内部是否有异常捕获处理,防止线程抛出异常而退出? |
N | 20 |
原子操作代码异常中断,使用的相关外部变量是否恢复先前状态? |
|
重要 |
Y | 100 |
函数对错误的处理是恰当的? |
可维护性 |
|||
重要 |
Y | 100 |
实现代码中是否消除了直接常量?(用于计数起点的简单常数例外) |
Y | 20 |
是否消除了导致结构模糊的连续赋值?(如a= (b=d+c )) |
|
N | 20 |
是否每个return前都要有日志记录? |
|
N | 20 |
是否有冗余判断语句?(如:if (b) return true; else return false;) |
|
Y | 20 |
是否把方法中的重复代码抽象成私有函数? |