Second team work

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

是否把方法中的重复代码抽象成私有函数?

四.任务评价

到了结对作业的第二次作业,其中队友负责全部代码的工作,这次作业是用java编写的,由于自身对java了解不多,作业出来后,我也是恶补了一些java的知识,与其说是完成作业,更多的是其中的学习,和队友一起思考,一起进步。起初我对于这些代码很是头疼,很容易就看不懂其中的意思,通过翻书等了解了语句的意思,进而懂得了要实现的东西,懂得了之后再去找可能出现的问题,编写单元测试检查代码的可实用性。

平时我是一个有点拖延症的人,几乎作业发布出来后,我都得拖个几天再去写作业。但是由于这次作业的特殊性和我的队友的积极性,我也很快的就投入到了作业中去,在这期间,队友不断地修改代码,我们还去图书馆借了有关图形界面的书(Qt),他还添加了许多作业没有要求的东西,在我看来,他并不是要完成作业,而是要把事情做得漂亮,我觉得这对于以后的工作很有帮助,他对待事情的认真性,让我受益颇多。队友的编程能力很强,但是他也会问我需要加什么东西进来,让结果看起来更好,对比上次作业,我们之间的交流多了许多,让我了解到自己的不足,更加努力的学习。

编写单元测试时,由于基础薄弱,队友在一旁很是耐心仔细的帮助我,一些遗漏的东西与不懂的问题,他都能给我很好的指点,让我很快认识到错误,了解自己将要完成什么。测试代码主要是先测试生成的式子是否合法,然后对产生的式子进行运算,看是否与理论值相符。开始编写的时候没有考虑到0,后来发觉除法是0作为除数的不合法性,我们又进行了一些修改,使这次的作业完成的很是完美。至此,最是感谢我的队友给予的帮助。

最后附上我们工作的照片

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324453694&siteId=291194637