Second pair programming assignment

Second pair programming assignment

1. Question selection: calculation question generation program

Require

It can automatically generate four arithmetic practice questions. The number of questions can be
customized . The
user can choose the operator. The
user can set the maximum number (such as within 10, within 100, etc. ) ) It is best to provide a graphical user interface (choose according to your own ability, mainly to complete the above functions)


The division of labor among members

Driver: Pang Guangdong
can complete all the code work, the program basically realizes all the required functions, and upload the code to coding.net or GitHub code hosting system 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

Pilot: Wang Shengyao
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.
According to the code checklist of the previous job, the driver can perform this work. Evaluation Be
able to complete a summary of more than 500 words on this work

Three, topic analysis

This homework requires a program that can generate calculation questions. It is required to select the number of generated questions, the maximum number, whether to include mixed operations, operators, etc. On top of these basic functions, the user can choose the output method (output to a file or a printer), preferably a graphical user interface. So we will split the project, first write the main kernel, that is, the part of the random generation formula, and then write how to choose the output method and the graphical user interface.

Fourth, the program code

(address) [ https://github.com/iacnixgnok/TitleGenerator ]

5. Running results and tests

(1) Code Review Form

Function module name
Examiner Wang Shengyao Review date 2018.4.5
code name lexical analysis code author Pang Guangdong
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? no
Whether to store only "declaration" and not "definition" in the header file no
program layout
importance       Review item in conclusion
Are blank lines appropriate? no
Are spaces within lines of code decent? Yes
Are long line splits decent? no
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. Yes
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? Yes
important Are the annotations wrong or could lead to misunderstandings? no
important Is the public, protected, private order of the class structure consistent across all programs? no
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? no
The length of the identifier should comply with the "min-length && max-information" principle? no
important Do the same local variables and all variables appear in the program? Yes
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? Yes
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? no
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
(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? Yes
Move to the outside of the loop body?
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
Are you using intuitive constants to represent numbers or strings that will appear multiple times in your program? no
在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)没有正确地关闭文件吗?

(2)检测结果

(3)结果展示


六、总结

本次结对编程作业可以说是让我对于结对编程这种工作方法有了一个深入的了解,同时也让我对于领航员和驾驶员这两个看似不同但是却又密不可分的位置有了全新的认识。

开始的构思阶段领航员和驾驶员必须进行完全的沟通,在互相确定了对方思路的前提下之后的编程和修改才能够进行的更加顺利。因为如果领航员不能清楚地了解到驾驶员的编程思路那么在编程途中想要找出一些深入的错误需要耗费极大的经历与集中力,这对于可能需要尝试间工作的程序员来说是一个十分沉重的负担。从另一个角度看,人的智慧是可以根据人数的多寡来改变的,两个人联合在一起的智慧总是能够强于一个人的智慧,所以结对进行程序设计也可以有些的提高两人的灵感,为编写提供支持。

之后的编程阶段则需要驾驶员和领航员的熟练配合,在编程的过程中代码先后需要经过两次检查,首先驾驶员在编写程序时需要自行对代码进行一次检查,但是作为程序的编写者总会在下意识里忽略一些错误,而这些错误就是身为旁观者的领航员需要去进行修正的地方。只有领航员和驾驶员通力合作才能够使程序里出现错误的概率降到最低。

最后要说的是,虽然结对编程有着种种好处,但是其中仍然有着一些不足。首先是如同老师所说这种编程方式不适合能力差距过大的人使用,因为如果差距较大很可能导致根本看不懂对方程序所表达的意思从而使两人中的一个完全无法发挥作用达不到结对编程的目的。其次是两人的关系不能太差不然很肯能导致互相拖后腿的事情发生。

总而言之,这次的结对编程作业进行的还算顺利,我与庞广东同学配合默契,成功的完成了作业所规定的任务。通过这次的合作,我们两个的编程水平也都获得了提升,很期待下次的合作。

Guess you like

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