青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

子彈 の VISIONS

NEVER back down ~~

C++博客 首頁 新隨筆 聯系 聚合 管理
  112 Posts :: 34 Stories :: 99 Comments :: 0 Trackbacks

From: http://www.macadamian.com/index.php?option=com_content&task=view&id=27&Itemid=31

Macadamian's Code Review Checklist 

At Macadamian, we practice what we preach with peer code reviews. Before we commit any code to source control, we check it for compliance with this list.

We’ve made the checklist public for the use of software development teams implementing code review as part of their process. For more information about code review processes and software development best practices, read check out the Critical Path newsletter – it’s free, too!

General Code Smoke Test
Comments and Coding Conventions
Error Handling
Resource Leaks
Control Structures
Performance
Functions
Bug Fixes
Math



 

General Code Smoke Test

Does the code build correctly?
No errors should occur when building the source code. No warnings should be introduced by changes made to the code.

Does the code execute as expected?
When executed, the code does what it is supposed to.

Do you understand the code you are reviewing?
As a reviewer, you should understand the code. If you don't, the review may not be complete, or the code may not be well commented.

Has the developer tested the code?
Insure the developer has unit tested the code before sending it for review. All the limit cases should have been tested.

Comments and Coding Conventions

Does the code respect the project coding conventions?
Check that the coding conventions have been followed. Variable naming, indentation, and bracket style should be used.

Does the source file start with an appropriate header and copyright information?
Each source file should start with an appropriate header and copyright information. All source files should have a comment block describing the functionality provided by the file.

Are variable declarations properly commented?
Comments are required for aspects of variables that the name doesn't describe. Each global variable should indicate its purpose and why it needs to be global.

Are units of numeric data clearly stated?
Comment the units of numeric data. For example, if a number represents length, indicate if it is in feet or meters.

Are all functions, methods and classes documented?
Describe each routine, method, and class in one or two sentences at the top of its definition. If you can't describe it in a short sentence or two, you may need to reassess its purpose. It might be a sign that the design needs to be improved.

Are function parameters used for input or output clearly identified as such?
Make it clear which parameters are used for input and output.

Are complex algorithms and code optimizations adequately commented?
Complex areas, algorithms, and code optimizations should be sufficiently commented, so other developers can understand the code and walk through it.

Does code that has been commented out have an explanation?
There should be an explanation for any code that is commented out. "Dead Code" should be removed. If it is a temporary hack, it should be identified as such.

Are comments used to identify missing functionality or unresolved issues in the code?
A comment is required for all code not completely implemented. The comment should describe what's left to do or is missing. You should also use a distinctive marker that you can search for later (For example: "TODO:francis").

Error Handling

Are assertions used everywhere data is expected to have a valid value or range?
Assertions make it easier to identify potential problems. For example, test if pointers or references are valid.

Are errors properly handled each time a function returns?
An error should be detected and handled if it affects the execution of the rest of a routine. For example, if a resource allocation fails, this affects the rest of the routine if it uses that resource. This should be detected and proper action taken. In some cases, the "proper action" may simply be to log the error.

Are resources and memory released in all error paths?
Make sure all resources and memory allocated are released in the error paths.

Are all thrown exceptions handled properly?
If the source code uses a routine that throws an exception, there should be a function in the call stack that catches it and handles it properly.

Is the function caller notified when an error is detected?
Consider notifying your caller when an error is detected. If the error might affect your caller, the caller should be notified. For example, the "Open" methods of a file class should return error conditions. Even if the class stays in a valid state and other calls to the class will be handled properly, the caller might be interested in doing some error handling of its own.

Has error handling code been tested?
Don't forget that error handling code that can be defective. It is important to write test cases that exercise it.

Resource Leaks

Is allocated memory (non-garbage collected) freed?
All allocated memory needs to be freed when no longer needed. Make sure memory is released in all code paths, especially in error code paths.

Are all objects (Database connections, Sockets, Files, etc.) freed even when an error occurs?
File, Sockets, Database connections, etc. (basically all objects where a creation and a deletion method exist) should be freed even when an error occurs. For example, whenever you use "new" in C++, there should be a delete somewhere that disposes of the object. Resources that are opened must be closed. For example, when opening a file in most development environments, you need to call a method to close the file when you're done.

Is the same object released more than once?
Make sure there's no code path where the same object is released more than once. Check error code paths.

Does the code accurately keep track of reference counting?
Frequently a reference counter is used to keep the reference count on objects (For example, COM objects). The object uses the reference counter to determine when to destroy itself. In most cases, the developer uses methods to increment or decrement the reference count. Make sure the reference count reflects the number of times an object is referred.

Thread Safeness

Are all global variables thread-safe?
If global variables can be accessed by more than one thread, code altering the global variable should be enclosed using a synchronization mechanism such as a mutex. Code accessing the variable should be enclosed with the same mechanism.

Are objects accessed by multiple threads thread-safe?
If some objects can be accessed by more than one thread, make sure member variables are protected by synchronization mechanisms.

Are locks released in the same order they are obtained?
It is important to release the locks in the same order they were acquired to avoid deadlock situations. Check error code paths.

Is there any possible deadlock or lock contention?
Make sure there's no possibility for acquiring a set of locks (mutex, semaphores, etc.) in different orders. For example, if Thread A acquires Lock #1 and then Lock #2, then Thread B shouldn't acquire Lock #2 and then Lock #1.

Control Structures

Are loop ending conditions accurate?
Check all loops to make sure they iterate the right number of times. Check the condition that ends the loop; insure it will end out doing the expected number of iterations.

Is the code free of unintended infinite loops?
Check for code paths that can cause infinite loops. Make sure end loop conditions will be met unless otherwise documented.

Performance

Do recursive functions run within a reasonable amount of stack space?
Recursive functions should run with a reasonable amount of stack space. Generally, it is better to code iterative functions.

Are whole objects duplicated when only references are needed?
This happens when objects are passed by value when only references are required. This also applies to algorithms that copy a lot of memory. Consider using algorithm that minimizes the number of object duplications, reducing the data that needs to be transferred in memory.

Does the code have an impact on size, speed, or memory use?
Can it be optimized? For instance, if you use data structures with a large number of occurrences, you might want to reduce the size of the structure.

Are you using blocking system calls when performance is involved?
Consider using a different thread for code making a function call that blocks.

Is the code doing busy waits instead of using synchronization mechanisms or timer events?
Doing busy waits takes up CPU time. It is a better practice to use synchronization mechanisms.

Was this optimization really needed?
Optimizations often make code harder to read and more likely to contain bugs. Such optimizations should be avoided unless a need has been identified. Has the code been profiled?

Functions

Are function parameters explicitly verified in the code?
This check is encouraged for functions where you don't control the whole range of values that are sent to the function. This isn't the case for helper functions, for instance. Each function should check its parameter for minimum and maximum possible values. Each pointer or reference should be checked to see if it is null. An error or an exception should occur if a parameter is invalid.

Are arrays explicitly checked for out-of-bound indexes?
Make sure an error message is displayed if an index is out-of-bound.

Are functions returning references to objects declared on the stack?
Don't return references to objects declared on the stack, return references to objects created on the heap.

Are variables initialized before they are used?
Make sure there are no code paths where variables are used prior to being initialized. If an object is used by more than one thread, make sure the object is not in use by another thread when you destroy it. If an object is created by doing a function call, make sure the object was created before using it.

Does the code re-write functionality that could be achieved by using an existing API?
Don't reinvent the wheel. New code should use existing functionality as much as possible. Don't rewrite source code that already exists in the project. Code that is replicated in more than one function should be put in a helper function for easier maintenance.

Bug Fixes

Does a fix made to a function change the behavior of caller functions?
Sometimes code expects a function to behave incorrectly. Fixing the function can, in some cases, break the caller. If this happens, either fix the code that depends on the function, or add a comment explaining why the code can't be changed.

Does the bug fix correct all the occurrences of the bug?
If the code you're reviewing is fixing a bug, make sure it fixes all the occurrences of the bug.

Math

Is the code doing signed/unsigned conversions?
Check all signed to unsigned conversions: Can sign completion cause problems? Check all unsigned to signed conversions: Can overflow occur? Test with Minimum and Maximum possible values.

posted on 2008-06-10 14:38 子彈のVISIONS 閱讀(974) 評論(1)  編輯 收藏 引用 所屬分類: 1.x 臨時目錄

Feedback

# re: Macadamian's Code Review Checklist 2010-08-23 09:27 dress
These two small addons perform a simple web site search either in the google groups or on CP. Select a piece of text in the code editor, right click to pop up the menu and then select where to search for   回復  更多評論
  

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美国产精品人人做人人爱| aa级大片欧美| 欧美第一黄网免费网站| 久久天堂成人| 免费欧美网站| 欧美日本网站| 国产欧美一区二区色老头| 国产精品视频免费在线观看| 国产麻豆91精品| 在线观看精品| 在线亚洲伦理| 久久人人97超碰人人澡爱香蕉| 欧美国产欧美亚洲国产日韩mv天天看完整| 欧美激情一区二区三区蜜桃视频| 亚洲精选成人| 欧美一区三区二区在线观看| 女同性一区二区三区人了人一 | 在线观看成人网| 一区二区国产日产| 欧美在线观看一区| 亚洲电影第三页| 9国产精品视频| 欧美专区在线播放| 欧美日韩一区二区三区| 尤物精品在线| 午夜精品久久久久| 最新国产精品拍自在线播放| 香蕉免费一区二区三区在线观看| 你懂的国产精品| 国产人成精品一区二区三| 亚洲精品日韩激情在线电影| 久久精品国产在热久久| 亚洲狼人综合| 欧美成人午夜剧场免费观看| 国产精品亚洲综合久久| 夜夜夜精品看看| 欧美第十八页| 久久精品中文字幕免费mv| 欧美日韩精品一区视频| 亚洲观看高清完整版在线观看| 欧美一区精品| 亚洲另类黄色| 欧美二区在线播放| 一色屋精品亚洲香蕉网站| 欧美一区二区三区久久精品茉莉花 | 欧美aⅴ一区二区三区视频| 国产欧美va欧美不卡在线| 亚洲婷婷在线| 99精品视频免费| 欧美大香线蕉线伊人久久国产精品| 国内外成人在线视频| 欧美在线综合视频| 亚洲欧美在线磁力| 国产精品无码永久免费888| 亚洲欧美日韩成人高清在线一区| 日韩亚洲一区二区| 欧美人妖另类| 99精品久久久| 日韩视频一区二区三区在线播放| 能在线观看的日韩av| 最新中文字幕一区二区三区| 欧美成人黑人xx视频免费观看| 久久九九全国免费精品观看| 国产一区欧美| 久久在线免费观看| 久久综合激情| 亚洲精品午夜精品| 亚洲精品欧美一区二区三区| 欧美日本中文| 亚洲视频1区| 亚洲香蕉在线观看| 国产裸体写真av一区二区| 久久精品久久综合| 久久婷婷国产综合尤物精品 | 国产一区二区高清视频| 久久深夜福利免费观看| 牛夜精品久久久久久久99黑人| 亚洲美女色禁图| 亚洲乱码国产乱码精品精98午夜 | 欧美xxx成人| 亚洲一区二区三区激情| 亚洲一区日本| 亚洲国产精品一区二区第一页 | 蜜臀久久久99精品久久久久久 | 免费亚洲一区| 欧美日韩一区二区三区高清| 久久国产精品99精品国产| 久久超碰97中文字幕| 亚洲国产精品ⅴa在线观看 | 亚洲人成网站精品片在线观看| 亚洲精品一级| 韩国精品一区二区三区| 亚洲国产婷婷综合在线精品| 国产精品久久国产三级国电话系列 | 午夜一区在线| 亚洲激情成人在线| 亚洲一区免费观看| 亚洲人成人一区二区在线观看| 亚洲天堂男人| 亚洲激情av| 欧美亚洲日本一区| 宅男噜噜噜66一区二区| 久久久精品五月天| 亚洲女同精品视频| 欧美大片91| 久久综合国产精品台湾中文娱乐网| 欧美成人免费网| 久久精品国产999大香线蕉| 欧美极品欧美精品欧美视频| 久久午夜电影| 国产精品影视天天线| 亚洲精品小视频| 亚洲国产成人porn| 欧美制服第一页| 欧美伊人久久大香线蕉综合69| 欧美成人精品在线| 麻豆精品国产91久久久久久| 国产精品乱子久久久久| 亚洲精品社区| 一本色道久久综合| 美日韩免费视频| 老色鬼精品视频在线观看播放| 国产精品自拍一区| 一区二区欧美在线| 99视频有精品| 欧美成人免费网| 欧美mv日韩mv亚洲| 伊人成综合网伊人222| 欧美一区二区高清| 欧美在线播放一区二区| 国产精品国产一区二区 | 欧美激情精品久久久| 欧美成人一区在线| 亚洲国产精品久久久久秋霞不卡 | 欧美成年人在线观看| 美国十次成人| 狠狠色2019综合网| 久久精品亚洲一区| 欧美成人免费va影院高清| …久久精品99久久香蕉国产| 久久久久久69| 欧美韩日一区二区| 一本色道久久综合亚洲精品不| 欧美精品免费观看二区| 亚洲精品在线免费观看视频| 99精品视频免费观看| 欧美日韩一级片在线观看| 亚洲一级黄色av| 久久精品一区二区三区四区| 国产亚洲视频在线| 久久资源在线| 亚洲人成毛片在线播放| 亚洲天堂第二页| 国产欧美精品xxxx另类| 欧美一区综合| 91久久精品美女| 亚洲欧美在线另类| 好看的日韩av电影| 欧美 日韩 国产 一区| 亚洲免费大片| 久久精品视频播放| 亚洲黄色在线视频| 国产精品久久久久永久免费观看 | 嫩草成人www欧美| 99视频有精品| 国产一区二区三区在线免费观看| 久久久久免费视频| 亚洲精品中文字幕女同| 久久激情视频免费观看| 亚洲欧洲另类| 国产伦精品一区二区三区视频孕妇| 久久九九热re6这里有精品| 亚洲精品欧美极品| 老司机久久99久久精品播放免费| 亚洲免费观看在线观看| 久久久亚洲精品一区二区三区 | 亚洲欧美在线一区| 亚洲第一天堂av| 欧美一区免费视频| 日韩一区二区久久| 国产一区二区三区高清| 欧美日韩www| 久久精品人人做人人综合| 亚洲免费观看高清在线观看 | 亚洲日本激情| 国产一区日韩一区| 欧美香蕉大胸在线视频观看| 久久这里有精品15一区二区三区| 亚洲一区黄色| 一区二区三区精品国产| 欧美电影在线免费观看网站| 久久国产88| 亚洲欧美日韩第一区| 一区二区三区日韩欧美精品| 激情综合视频| 国产亚洲欧美一区二区| 欧美亚洲成人免费| 欧美日本一区| 欧美精品v日韩精品v韩国精品v | 久久中文字幕一区|