small team two

1. Topic selection

Portal: Software Engineering (2018) Pair Programming Second Assignment

After the discussion between the two of us, we chose topic 1:

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. Role determination

    Pilot: Liang Heng

  • It can assist the driver to complete all the code work, and select appropriate coverage standards for key functions to design test cases, and write code for unit automatic testing
  • Ability to evaluate the driver's current work based on the code checklist from the previous work
  • Able to complete a summary of more than 500 words on this work

    Driver: Hao Zhirong

  • Able to complete all code work, the program basically realizes all required functions, and upload the code to coding.net or GitHub code hosting system
  • Be able to give an objective evaluation of the role played by the navigator in this programming work, and complete a summary of more than 500 words

3. Unit testing

Based on driver Hao Zhirong's code, I did the following junit unit test:

1) Randomly generate integer function test

  • Function introduction:
    int get_random_int(int minmun,int maxmun) Randomly output an integer between minmun and maxmun
test case parameter expect results
1 0,0 0
2 10,0 0
3 0,10 0~9

2) User input test
Since there are a lot of user inputs, only the presence or absence of parentheses is tested here.
The test results are as follows:

## 4. Code review:

Reviewer: Liang Heng

Code author: Hao Zhirong

Code content: automatic generation program of four arithmetic operations in primary school

Review date: 2018.4.15

Review list:

Function module name Primary school four arithmetic automatic generation program 
file structure
importance       Review item in conclusion
                 Are the names of the header and definition files reasonable?  Yes
  Is the directory structure of header files and definition files reasonable?  Yes
  Are the copyright and version notices complete?  no
important Does the header file use ifndef/define/endif preprocessor blocks?  Yes
  Whether to store only "declaration" and not "definition" in the header file  no
program layout
importance       Review item in conclusion
  Are blank lines appropriate?  Yes
  Are spaces within lines of code decent?  Yes
  Are long line splits decent?  Yes
  Are "{" and "}" on each line and aligned in the same column?  Yes
important Does a line of code only do one thing? If only one variable is defined, write only one statement.  no
important If, for, while, do and other statements occupy their own line, no matter how many statements are executed, "{}" must be added.  Yes
important When defining a variable (or parameter), do you place the modifiers * and & right next to the variable name? Are the annotations clear and necessary?  no
important Are the annotations wrong or could lead to misunderstandings?  Yes
important Is the public, protected, private order of the class structure consistent across all programs?  Yes
     
naming convention 
importance       Review item in conclusion
important Are the naming conventions consistent with the style of the operating system or development tool used?  Yes
  Are the identifiers intuitive and spellable?  Yes
  The length of the identifier should comply with the "min-length && max-information" principle?  Yes
important Do the same local variables and all variables appear in the program?  no
  Does the writing format of class names, function names, variables and parameters, and constants follow certain rules?  Yes
  Are static variables, global variables, and class member variables prefixed?  no
     
Expressions and Basic Statements 
importance       Review item in conclusion
important If there are many operators on a line of code, have parentheses been used to clearly determine the order of operations of the expressions?  Yes
  Are you writing compound expressions that are too complex or multipurpose?  no
important Confuse compound expressions with "true math expressions"?  no
important Is the if statement written in an implicitly wrong way? For example  no
  (1) Compare the Boolean variable directly with TRUE, FALSE or 1, 0.  no
  (2) Use "==" or "!=" to compare floating point variables with any number.  no
  (3) Compare the pointer variable with NULL with "==" or "!=".  no
  If there is a logical judgment in the loop body and the number of loops is very large, has the logical judgment been made?  no
  Move to the outside of the loop body?  no
important Did you forget to add break at the end of the Case statement?  no
important Did you forget to write the default branch of switch?  no
important Are there any hidden dangers when using the goto statement? For example, some object construction, variable initialization, important calculations, etc. are skipped.  no
     
constant 
importance       Review item in conclusion
  是否使用含义直观的常量来表示那些将在程序中多次出现的数字或字符串?  是
  在C++ 程序中,是否用const常量取代宏常量?  否
重要 如果某一常量与其它常量密切相关,是否在定义中包含了这种关系?  否
  是否误解了类中的const数据成员?因为const数据成员只在某个对象  否
  生存期内是常量,而对于整个类而言却是可变的。  否
     
函数设计 
重要性       审查项 结论
  参数的书写是否完整?不要贪图省事只写参数的类型而省略参数名字。  否
  参数命名、顺序是否合理?  是
  参数的个数是否太多?  是
  是否使用类型和数目不确定的参数?  否
  是否省略了函数返回值的类型?  否
  函数名字与返回值类型在语义上是否冲突?  否
重要 是否将正常值和错误标志混在一起返回?正常值应当用输出参数获得,而错误标志用return语句返回。  否
重要 在函数体的“入口处”,是否用assert对参数的有效性进行检查?  否
重要 使用滥用了assert? 例如混淆非法情况与错误情况,后者是必然存在的并且是一定要作出处理的。  否
重要 return语句是否返回指向“栈内存”的“指针”或者“引用”?  否
  是否使用const提高函数的健壮性?const可以强制保护函数的参数、返回值,甚至函数的定义体。“Use const whenever you need”  否
     
内存管理 
重要性       审查项 结论
重要 用malloc或new申请内存之后,是否立即检查指针值是否为NULL?(防止使用指针值为NULL的内存)  否
重要 是否忘记为数组和动态内存赋初值?(防止将未被初始化的内存作为右值使用)  否
重要 数组或指针的下标是否越界?  否
重要 动态内存的申请与释放是否配对?(防止内存泄漏)  否
重要 是否有效地处理了“内存耗尽”问题?  是
重要 是否修改“指向常量的指针”的内容?  否
重要 是否出现野指针?例如(1)指针变量没有被初始化;(2)用free或delete释放了内存之后,忘记将指针设置为NULL。  否
重要 是否将malloc/free 和 new/delete 混淆使用?  否
重要 malloc语句是否正确无误?例如字节数是否正确?类型转换是否正 确?  是
重要 在创建与释放动态对象数组时,new/delete的语句是否正确无误?  是
     
C++ 函数的高级特性 
重要性       审查项 结论
  重载函数是否有二义性?  否
重要 是否混淆了成员函数的重载、覆盖与隐藏?  否
  运算符的重载是否符合制定的编程规范?  否
  是否滥用内联函数?例如函数体内的代码比较长,函数体内出现循环。  否
重要 是否用内联函数取代了宏代码?  否
     
类的构造函数、析构函数和赋值函数
重要性       审查项 结论
重要 是否违背编程规范而让C++ 编译器自动为类产生四个缺省的函数:  否
  (1)缺省的无参数构造函数;  否
  (2)缺省的拷贝构造函数;  否
  (3)缺省的析构函数;  否
  (4)缺省的赋值函数。  否
重要 构造函数中是否遗漏了某些初始化工作?  是
重要 是否正确地使用构造函数的初始化表?  否
重要 析构函数中是否遗漏了某些清除工作?  否
  是否错写、错用了拷贝构造函数和赋值函数?  否
重要 赋值函数一般分四个步骤:  
  (1)检查自赋值;  否
  (2)释放原有内存资源;  否
  (3)分配新的内存资源,并复制内容;  否
  (4)返回 *this。是否遗漏了重要步骤?          无
重要 是否正确地编写了派生类的构造函数、析构函数、赋值函数?  无
  注意事项:  
  (1)派生类不可能继承基类的构造函数、析构函数、赋值函数。  无
  (2)派生类的构造函数应在其初始化表里调用基类的构造函数。  无
  (3)基类与派生类的析构函数应该为虚(即加virtual关键字)。  无
  (4)在编写派生类的赋值函数时,注意不要忘记对基类的数据成员重新赋值  无
     
类的高级特性
重要性       审查项 结论
重要 是否违背了继承和组合的规则?  否
 无 (1)若在逻辑上B是A的“一种”,并且A的所有功能和属性对B而言都有意义,则允许B继承A的功能和属性。  无
  (2)若在逻辑上A是B的“一部分”(a part of),则不允许B从A派生,而是要用A和其它东西组合出B。  否
 否    
其它常见问题 
重要性       审查项 结论
重要 数据类型问题:  否
  (1)变量的数据类型有错误吗?  否
  (2)存在不同数据类型的赋值吗?  否
  (3)存在不同数据类型的比较吗?  否
重要 变量值问题:  否
  (1)变量的初始化或缺省值有错误吗?  否
  (2)变量发生上溢或下溢吗?  否
  (3)变量的精度够吗?          是
重要 逻辑判断问题:  是
  (1)由于精度原因导致比较无效吗?  否
  (2)表达式中的优先级有误吗?  否
  (3)逻辑判断结果颠倒吗?          否
重要 循环问题:  否
  (1)循环终止条件不正确吗?  否
  (2)无法正常终止(死循环)吗?  否
  (3)错误地修改循环变量吗?  否
  (4)存在误差累积吗?          否
重要 错误处理问题:  
  (1)忘记进行错误处理吗?  否
  (2)错误处理程序块一直没有机会被运行?  否
  (3)错误处理程序块本身就有毛病吗?如报告的错误与实际错误不一致,处理方式不正确等等。  否
  (4)错误处理程序块是“马后炮”吗?如在被它被调用之前软件已经出错。  否
重要 文件I/O问题:  
  (1)对不存在的或者错误的文件进行操作吗?  否
  (2)文件以不正确的方式打开吗?  否
  (3)文件结束判断不正确吗?  否
  (4)没有正确地关闭文件吗?  否
     

5.领航员结对编程总结

  此次结对编程,我的角色是领航员,我的partner郝志荣的角色就是是驾驶员啦。刚开始还以为领航员的任务应该会是轻松一点的,但是当和郝志荣一起结对编程时才发现,理想总是很美好的,现实却有点残酷。说的是简单,领航员能够辅助驾驶员完成全部代码工作,并且为关键函数选用合适的覆盖标准设计测试用例,并编写代码进行单元自动测试就好,真正一起干活了才发现,还是很麻烦的。郝志荣他上学期选了java这门选修课,而且这次我们选的题目,用java做也比较简单,所以我们选择了java编程。而我对java也算是小白,所以编程时我都要时不时的请教郝志荣,因为我们是舍友,所以我们可以很方便的在晚上一起学习。这次结对编程,在郝志荣的帮助下,自己也学到了点java的知识。自己再对他编好的程序进行测试,找测试的覆盖标准,再写代码复审表。对于结对编程,我的感觉还是很美好的,它虽然也有别人说的两个人的编程习惯有分歧,时间也有时候是限制结对编程的原因,但我个人看来它的优点还是要盖过这些缺点的,它让我们变得更加的爱与别人交流,交流自己的想法,能够增加我们之间的感情。当然结对编程对我们的知识也会是一种补充,知识是一种一加一大于二的东西,分享知识当然也是快乐的。虽然我们的水平还是有限,但在我们各司其职,尽自己的最大努力,完成这个小程序时,还是有种非常自豪的喜悦的,当有人一起分享喜悦时,感受到的会是幸福。还是那就句话,革命尚未成功,同志仍需努力,希望在以后的结对作业时,我们俩能够磨合的更加默契,更好更快的解决问题,完成项目。加油!

6.领航员And驾驶员工作照

Guess you like

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