Software engineering - team work 3

A. Code specification and coding principles

typesetting

  1. Add the appropriate space between keywords and operators. 
  2. The independent procedures between the blocks plus blank lines 
  3. longer statements, expressions, etc. to be divided into multiple lines written. 
  4. partitioned indent the new row to adapt the layout neat, readable statements. 
  5. Long expression to divide a new line in the low priority operator, the operator of the new line on the first. 
  6. cycle and judgment statement if the statement or expression longer, will have to be divided adaptation. 
  7. If the function or process parameters is longer, it will have to be properly divided. 
  8. do not allow more than the short statement written on one line, that line of writing only one statement. 
  9. Start function or process, and the cycle definition structure, judgment of code statements have indented style. 
  10.C / C ++ languages braces '{' and '}' define a program block, when the write block '{' and '}' should each separate line and in the same column, while statements that reference them with the left alignment. In the beginning of the function of the definition of class definition of the structure, and the definition of the enumeration if, for, do, while, switch, case statement must procedure as above using indentation.

Note

  1. Notes should be simple and straightforward. 

  2. The side edge writing code comments, modify the code at the same time modify the notes, in order to ensure consistency with the annotated code. 

  3. Where necessary annotations, to moderate volume. The content of comments to make it clear, clear, precise meaning, to prevent ambiguity comment. Notes held adjacent thereto description code, i.e., annotations proximity principle. 

  4. Note that the code should be placed adjacent to the top position, not at the bottom.

  5. Note the data structure should be placed adjacent to its upper position, can not be placed below; annotations to the structure of each field should be placed to the right of this domain; Note the same structure to align different domains. 

  6. variables, constants should be placed above it notes or rightward adjacent positions. 

  7. The global variables to have more detailed annotations, including its function, the range, in which it functions or procedures and precautions access accessing FIG. 

  8. Notes have the necessary information in the header of each source file, comprising: a file name; version number; OF; creation date; (e.g., the main algorithm, the relationship between the parts of the internal module functions described functions, the file relationship to other files, etc.); the main function or procedure list and modify this file history records. 
  9. In front of each have a function or procedure necessary comment information, comprising: a function or procedure name; Functional Description; input, output and return value; call relations and relationships are called descriptions.

name

  1. The shorter word may be formed by removing the abbreviation "vowel"; 

  2. longer words preferably the first few words of priority hair breaks, and explicit expressions in parentheses sequence of operations, to avoid using the default priority.

readability

  1. Avoid the use of digital easily understood, instead of a meaningful identity. 
    2. Do not use a high skill statement difficult to understand. 
  3. The relationship between the source program code should more closely adjacent as possible.

variable  

  1. Remove unnecessary public variables. 

  2. construct only one module or function can be modified, created, while the rest of the relevant module or function only access public variables, to prevent a number of different modules or functions can be modified to create the same phenomenon common variables. 
  3. Carefully and clearly define the meaning of common variables, the relationship between the role and the range of public variables. 
  4. clear public relations function or variable process variables and operation of this public, such as access, modify and create and so on. 
  5. When passing data to the public variables, to be very careful to prevent unreasonable and so endowed with value or cross-border phenomenon. 
  6. prevent local variable with the same name and public variables. 
  7. The layout of the order of elements in the structure of carefully designed the structure can be easily appreciated, to save space, and reduce the phenomenon caused by misuse. 
  8. The structure designed to try to consider and forward-compatible later version upgrades, and possible future applications for some leeway retained (as set aside some space, etc.). 
  9. A careful and specific language compiler principles of different types of data and relevant details. 
  10. Do not use uninitialized variables. At the same time declaring variables initialize variables. 
  11. programming, pay attention to cast data types.

Function procedure

  1. Try to limit the size of the function of less than 200 lines. 
  2. A function is best done only one function. 
  3. Write a function is a simple function. 
  4. Function function should be predictable, i.e. the same as long as the input data should produce the same output. 
  5. Try not to write a function dependent on other internal functions to achieve. 
  6. avoid designing function of multiple parameters, the parameters are not removed from the used interface. 
  7. The effect of the relationship between each parameter, with ranges and parameters detailed comments. 
  8. All input parameters validity check function. 
  All non-validity check function 9. The input parameters, such as data files, the public variables. 
  10. The function name should accurately describe the function of the function. 
  11. Avoid using meaningless or ambiguous verb a function named 
  return value of 12. The function to clear, clear, so that users do not easily ignore the error condition. 
  13 / function-specific, exact (rather than approximately) function is designed to achieve. 
  14. The decrease between the recursive function itself or function call. 
  15. The write function is reentrant, the use of global variables should be closed by an interrupt, the signal amount (i.e., P, V operation) and other means to protect them.

Testability

  1. Before writing code, design methods and means should be pre-programmed to debug and test, commissioning and design a good variety of switches and the corresponding test code, such as print function or the like. 
  2. Before carrying out integration testing / system the FBI, to construct a good test environment, test items and test cases, and carefully analyze and optimize test cases to improve test efficiency.

Efficiency program

  1.编程时要经常注意代码的效率。 
  2.在保证软件系统的正确性、稳定性、可读性及可测性的前提下,提高代码效率。 
  3.不能一味地追求代码效率,而对软件的正确性、稳定性、可读性及可测性造成影响。 
  4.编程时,要随时留心代码效率;优化代码时,要考虑周全。 
  5.要仔细地构造或直接用汇编编写调用频繁或性能要求极高的函数。 
  6.通过对系统数据结构划分与组织的改进,以及对程序算法的优化来提高空间效率。 
  7.在多重循环中,应将最忙的循环放在最内层。 
  8.尽量减少循环嵌套层次。 
  9.避免循环体内含判断语句,应将循环语句置于判断语句的代码块之中。 
  10.尽量用乘法或其它方法代替除法,特别是浮点运算中的除法。

质量保证

  1.在软件设计过程中构筑软件质量。 
  代码质量保证优先原则 
  (1)正确性,指程序要实现设计要求的功能。 
  (2)稳定性、安全性,指程序稳定、可靠、安全。 
  (3)可测试性,指程序要具有良好的可测试性。 
  (4)规范/可读性,指程序书写风格、命名规则等要符合规范。 
  (5)全局效率,指软件系统的整体效率。 
  (6)局部效率,指某个模块/子模块/函数的本身效率。 
  (7)个人表达方式/个人方便性,指个人编程习惯。 
  2.只引用属于自己的存贮空间。 
  3.防止引用已经释放的内存空间。 
  4.过程/函数中分配的内存,在过程/函数退出之前要释放。 
  5.过程/函数中申请的(为打开文件而使用的)文件句柄,在过程/函数退出前要关闭。 
  6.防止内存操作越界。 
  7.时刻注意表达式是否会上溢、下溢。 
  8.认真处理程序所能遇到的各种出错情况。 
  9.系统运行之初,要初始化有关变量及运行环境,防止未经初始化的变量被引用。 
  10.系统运行之初,要对加载到系统中的数据进行一致性检查。 
  11.严禁随意更改其它模块或系统的有关设置和配置。 
  12.不能随意改变与其它模块的接口。 
  13.充分了解系统的接口之后,再使用系统提供的功能。 
  14.要时刻注意易混淆的操作符。当编完程序后,应从头至尾检查一遍这些操作符。 
  15.不使用与硬件或操作系统关系很大的语句,而使用建议的标准语句。 
  16.建议:使用第三方提供的软件开发工具包或控件时,要注意以下几点: 
  (1)充分了解应用接口、使用环境及使用时注意事项。 
  (2)不能过分相信其正确性。 
  (3)除非必要,不要使用不熟悉的第三方工具包与控件。

代码编译

  1.编写代码时要注意随时保存,并定期备份,防止由于断电、硬盘损坏等原因造成代码丢失。 

  2.同一项目组内,最好使用相同的编辑器,并使用相同的设置选项。 
  3.合理地设计软件系统目录,方便开发人员使用。 
  4.打开编译器的所有告警开关对程序进行编译。 
  5.在同一项目组或产品组中,要统一编译开关选项。 
  6.使用工具软件(如VisualSourceSafe)对代码版本进行维护。

代码测试

  1.单元测试要求至少达到语句覆盖。 
  2.单元测试开始要跟踪每一条语句,并观察数据流及变量的变化。 
  3.清理、整理或优化后的代码要经过审查及测试。

二.数据库设计

 

三.ER图

 

四.主要功能流程描述

 

五.作业分工

史浩欣:代码规范及编码原则

朱苏洵:数据库设计

温秀连:ER图

周黎:主要功能流程描述

六.组员贡献分

史浩欣:10分

朱苏洵:10分

温秀连:10分

周黎:10分

Guess you like

Origin www.cnblogs.com/666xin/p/10963604.html