Checklist and summary-code Daquan

Source: Internet
Author: User
Tags case statement comparison table integer division

Design

  • Does the design go through multiple iterations and ultimately decide the best one?
  • Are top-down and bottom-up methods used to solve design problems?
  • Has the interaction between classes been designed to be minimized?
  • Is the design divided into layers?
  • Are you satisfied with the method of decomposing this program into subprograms, packages and classes?
  • Is the program easy to maintain?
  • Is the Design Simplified? Is every part of the design absolutely necessary?
  • On the whole, does your design help minimize unexpected and essential complexity?

Class Design

  • Do you think of all classes in the program as abstract data types? Are their interfaces evaluated from this perspective?
  • Does the class have a central purpose?
  • Is the class name appropriate? Does its name express its new purpose?
  • Does the class interface display consistent abstraction?
  • Can a class interface clearly understand how to use it?
  • Is the class interface abstract so that you don't have to worry about how it implements its service? Can you think of classes as black boxes?
  • Is the services provided by the class complete enough so that other classes do not need to use their internal data?
  • Has no irrelevant information been removed from the class?
  • Have you considered further decomposition of classes?
  • Does it maintain the integrity of its interface when modifying a class?
  • Minimize the accessibility of members?
  • Do you want to avoid exposing data members of the class?
  • Does the class avoid making assumptions about its users, including how its derived classes use it?
  • Does the class depend on other classes? Is it loosely coupled?
  • Is Inheritance only used to establish an is-a relationship? Whether the derived class complies with the LSP principle.
  • Is the hierarchy quite simple?
  • Is there only about seven or fewer Members in the class?
  • Do you want to minimize the number of subprograms that call other classes directly or indirectly?
  • Is the class written with other classes when absolutely necessary?
  • Are all data members initialized in the constructor?

Subroutine

  • Is there a sufficient reason to create a subroutine?
  • Have all the parts suitable for separate proposal in a sub-program been put into a separate sub-program?
  • Does the process name use a strong and clear Verb plus an object phrase, and does the function name describe its return value?
  • Does the subprogram name describe everything it does?
  • Does a subroutine have strong functional cohesion?
  • Are there loose coupling between subprograms? Is the connection between subprograms and other subprograms minimal, clear, visible, and flexible?
  • Is the length of a subroutine determined by its functions and logic, rather than following any human encoding standard?
  • Does the parameter table of a subroutine show a holistic and consistent abstraction?
  • Is the ordering of subroutine parameters reasonable? Is it consistent with the parameter arrangement of similar subprograms?
  • Is the interface described in this document?
  • Are there no more than 7 subroutine parameters?
  • Have you used every input parameter and every output parameter?
  • Does a subroutine avoid using input parameters as work variables?
  • If a subroutine is a function, can it return a valid value whenever possible?

Defense Programming

  • Does a subroutine protect itself from harmful input data?
  • Do you use assertions to describe programming assumptions? Are the pre-and post-conditions included?
  • Does an assertion only indicate what should never happen?
  • Do you specify a specific set of error handling techniques in the architecture or high-level design?
  • Do you specify in the architecture or high-level design whether to make error handling more robust or correct?
  • Is the code used for auxiliary debugging?
  • Is the amount of Code introduced in defensive programming appropriate?
  • Have you defined a standardized Exception Handling solution in the project?
  • If possible, have you processed the error locally instead of running it out as an exception?
  • Are all exceptions at the same abstraction level as the subprograms that throw them?
  • Does each exception contain all background information about the exception?
  • Is there no empty catch statement in the code?
  • Check whether the code that is harmful to input data is also checked for deliberate buffer overflow, SQL injection, HTML injection, integer overflow and other malicious input data?
  • Check all error return codes?
  • Have all exceptions been caught?
  • Do error messages avoid information required by attackers to attack the system?

Pseudocode

  • Have you checked that all prerequisites have been met?
  • Have you defined the problem to be solved for this class?
  • Is the high-level design clear? Can you give a good name to this class and each of them subprograms?
  • Have you considered how to test this class and every subroutine in it?
  • Regarding efficiency, do you mainly consider stable interfaces and readable implementations? Or is it mainly from the perspective of meeting the resource and speed expectations?
  • Have you searched for available subroutines or components from standard library functions and other code libraries?
  • Have you found any useful algorithms in the reference books?
  • Is every subroutine well designed with detailed pseudocode?
  • Have you checked the pseudocode in your mind? Are these pseudocodes easy to understand?
  • Have you followed the warning messages that may bring you back to design?
  • Is the pseudocode correctly translated into code?
  • Have you repeatedly used the pseudo-code programming process?
  • Do I describe them when making assumptions?
  • Have the redundant comments been deleted?
  • Have you taken the best result of several iterations? Or is it stopped after the first iteration?
  • Do you fully understand your code? Are these codes easy to understand?

Variable

  • Is the declared position of a variable close to the position used for the first time?
  • Should I initialize the variable while declaring the variable?
  • Have counters and accumulators been properly initialized? If you need to use it again, have you reinitialized it before?
  • Should I reinitialize the variable in the code that needs to be repeated?
  • Is there no warning when the code is compiled by the compiler? Have you enabled all available warning messages?
  • If the language permits implicit declaration, do you take appropriate compensation measures for the problems that may arise?
  • If possible, are all variables defined as having the smallest scope?
  • Are the reference points of each variable as concentrated as possible? Does this happen to the two adjacent references of the same variable or the entire life cycle of the variable?
  • Does the control structure conform to the data type?
  • Are all declared variables used?
  • Are all variables bound at the right time? That is to say, Do You consciously balance the flexibility brought about by late binding with increased complexity?
  • Does each variable have only one purpose?
  • Does each variable have a clear meaning and no implicit meaning?

Variable name

  • Is the name complete and accurate to express the meaning of the variable?
  • The name is long enough, so you don't have to worry about it?
  • If there is a computing qualifier, is it placed behind the name?
  • Is num removed by using count or index in the name?
  • Does the name of the loop small mark make sense?
  • Are all temporary variables renamed as more meaningful names?
  • Can a Boolean variable accurately express its meaning when it is true?
  • Does the name in the enumeration contain the prefix or suffix that can represent its category?
  • Is a named constant named based on the abstract entity it represents, not the number it represents?
  • Can naming rules distinguish between local data, class data, and global data?
  • Can the rule distinguish between type names, named constants, enumerated types, and variable names?
  • Can a rule represent input parameters of a subroutine in a language where the compiler does not forcibly detect read-only parameters?
  • Can rules be compatible with standard language rules as much as possible?
  • Is the name formatted for readability?
  • Do you want to avoid abbreviations that only save one character?
  • Are all words abbreviated in the same way?
  • Can the name be read?
  • Do you want to avoid names that are easy to read or read?
  • Is the end name described in the abbreviation comparison table?

Basic Data Type

  • Do you want to avoid using mysterious values in the code?
  • Has the Code considered the division by zero error?
  • Is the type conversion obvious?
  • If a statement contains two different types of variables, will this statement be evaluated as expected?
  • Does the code avoid mixed type comparison?
  • Can an integer division expression work as expected?
  • Does the integer expression avoid integer overflow?
  • Does the code avoid the addition and subtraction operations on specific floating points with different orders of magnitude?
  • Does the code systematically prevent the occurrence of a rounding error?
  • Does the code avoid comparing floating point values?
  • Does the code avoid using mysterious characters and strings?
  • Does the off-bye-one error be avoided when a string is used?
  • Does the program use an extra Boolean variable to explain the condition judgment?
  • Does the program use an extra Boolean variable to simplify condition judgment?
  • Does the program use Enumeration type instead of a named constant to improve readability and modify rows?
  • When variables cannot be expressed as true or false, does the program replace Boolean variables with enumeration types?
  • Is the illegal value detected for the enumeration type?
  • Do I keep the first entry of the enumeration type as "invalid?
  • Are named constants consistent? Do I use a named constant in some locations and a text volume in other locations?
  • Are all arrays marked below the array boundary not exceeded?
  • No off-by-one error occurs in array reference?
  • Are the subscripts of all multidimensional arrays correct?
  • In a nested loop, do we use the correct variables in the array subscript to avoid the subscript confusion?

Uncommon Data Types

  • Do you use struct instead of variables to organize data related to operations?
  • Have you considered creating a class to replace struct?
  • Are all variables local or within the class range? Unless absolutely necessary, is it global?
  • Do you document all global variables?
  • Do you want to avoid the use of pseudo global data, that is, a huge object that is transmitted everywhere and contains messy data?
  • Is global data replaced by accessors?
  • Have you organized the access subprograms and data into the class?
  • Does the accessors subprogram provide an abstraction layer above the underlying data type implementation?
  • Are all related accessors subprograms located on the same abstraction layer?
  • Is pointer operations isolated from subprograms?
  • Is pointer reference legal? Or can a pointer become a floating pointer?
  • Does the code check its validity before using the pointer?
  • Check whether the pointer is valid before using the variable pointed to by the pointer?
  • After the pointer is used up, is it set to null?
  • For readability, does the Code use all the pointer variables that need to be used?
  • Are pointers in the linked list released in the correct order?
  • The program allocates a reserved memory reserve area so that it can exit gracefully when the memory is exhausted?
  • Is pointer used only when no other method is available?

Organize linear code

  • Does Code make the dependency between statements obvious?
  • Does the subprogram name make the dependency obvious?
  • Does the subprogram parameters make the dependency obvious?
  • If the dependency is unclear, are you using annotations?
  • Have you used "Housekeeping variable" to check the sequential dependency between key locations in the code?
  • Is the code easy to read in the top-down order?
  • Are related statements organized together?
  • Do I put a relatively independent statement group in their own subprograms?

Conditional statements

  • Is the normal code path clear?
  • Is the if-then method correct for processing the same number of branches?
  • Have you used the else statements and explained them?
  • Is Else correct?
  • If and else words are used, isn't They reversed?
  • Is the normal condition that needs to be executed to maintain if rather than in else statements?
  • If-then-else-If encapsulate complicated judgments into Boolean functions?
  • If-then-else-if is the most common condition first?
  • If-then-else-if is used to determine whether all conditions are included?
  • If-then-else-if is the best implementation? Is it better than the case statement?
  • Is case clause sorting meaningful?
  • Is the case clause easy to operate in every situation? Have other subprograms been called when necessary?
  • The case statement detects a real variable, rather than deliberately creating a variable to abuse the case statement?
  • Is the default statement valid?
  • Can I use the default words to detect and report unexpected situations?
  • In C, C ++, and Java, is there a break at the end of each case?

Loop

  • Is the for loop replaced by a while loop under the appropriate circumstances?
  • Is the loop created from the inside out?
  • Is it from the loop header into the loop?
  • Is the initialization Code directly in front of the loop?
  • Is a loop an infinite loop or an event loop? Is Ade's structure clear?
  • Do you want to avoid code like for I = 1 to 9999?
  • If this is a for loop in C ++, C, or Java, will the loop header be left to the loop control code?
  • {} And its equivalents are used cyclically to enclose the upper loop body, so as to prevent errors due to improper modification?
  • Is there content in the loop body? Is it not empty?
  • Has the internal affairs processing been concentrated at the beginning or end of the loop?
  • Does a loop execute only one operation like a well-defined subroutine?
  • Is the short cycle clear enough?
  • Is the nested hierarchy of a loop no more than three layers?
  • Is the content of a long loop extracted into a separate subroutine?
  • If the cycle is long, is it clear?
  • If this is a for loop, does the code arbitrarily modify the lower mark of the loop?
  • Do you want to save the important subscripts of the loop in another variable instead of using them in vitro?
  • Is the cyclic subscript of the ordinal or enumeration type, not the floating point type?
  • Does the name of the mark under the loop make sense?
  • Does loop avoid subscripts?
  • Can a loop be terminated under all possible conditions?
  • If a security counter standard is set up, is the security counter used cyclically?
  • Is the exit condition of the loop clear?
  • If break or continue is used, are they correct?
  • Uncommon control structures
  • Does every subroutine use return only when necessary?
  • Does using return help enhance readability?
  • Does recursive subprograms contain code for stopping recursion?
  • Does the subroutine use a security counter to ensure that the subroutine can be stopped?
  • Is recursion only in one sub-program?
  • Is the recursive depth of a subroutine within the limit that the program stack capacity can meet?
  • Is recursion the best way to implement subprograms? Is it better than a simple iteration?
  • Is goto used as a last resort? If goto is used, is it only for enhanced readability and maintainability?
  • If goto is used because of the efficiency factor, do you want to measure and explain the improvement in efficiency?
  • Does a sub-program only use one goto label at most?
  • Do all goto jump forward instead of backward?
  • Are all the Goto labels used?

Table-Driven Method

  • Have you considered using the table-driven method as an alternative to complex logic?
  • Have you considered using the table-driven method as an alternative to the complex inheritance structure?
  • Have you considered storing table data outside and reading it during running so that the data can be changed without modifying the code?
  • If you cannot access the table with a simple array index, do you extract the acid access key value function into a separate subroutine instead of re-calculating the key value in the code?

General Control Problems

  • Are values true and false in the expression, instead of 1 and 0?
  • Is a Boolean value compared with true or false implicitly?
  • Is the comparison of values explicitly performed?
  • Does it simplify expressions by adding new Boolean variables and using Boolean functions and decision tables?
  • Is a Boolean expression expressed in the affirmative form?
  • Matching brackets?
  • Do I use brackets when brackets are needed to define them?
  • Are you sure you want to write it in the order of number axes?
  • If appropriate, does the judgment in Java use the. Equals (B) method instead of the = B method?
  • Are empty statements clearly expressed?
  • Re-judge some conditions, is it possible to convert it to an if-then-else or case statement, extract the nested code into a separate subroutine, and convert it into a more object-oriented design or other improvement methods to simplify nested statements?
  • If there are more than 10 decision points for a sub-program, can we give a reason not to redesign it?

Checklist and summary-code Daquan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.