我的博客做業week2

一. 是否須要有代碼規範程序員

  對因而否須要有代碼規範,請考慮下列論點並反駁/支持:算法

     1.這些規範都是官僚制度下產生的浪費你們的編程時間、影響人們開發效率, 浪費時間的東西。編程

    反駁:代碼規範體現友好性,就像語言、貨幣全國通行,方便咱們使用和交流數組

     2.我是個藝術家,手藝人,我有本身的規範和原則。數據結構

    反駁:程序員不一樣,算法思路不一樣,最後寫出來的程序各有不一樣,這是必然的,在尊重這樣的多樣性的前提下,就更該規範代碼以使別人更快理解接受你的思路想法,否則在千奇百怪的代碼中再用上千奇百怪的規則,實在難以讓人吃得消,可維護性可見一斑ide

     3.規範不能強求一概,應該容許不少例外。模塊化

    支持:須要有規範,可是不能有一個絕對的規範,不然當新的語言新的類型誕生的時候其發展可能會受到阻礙函數

     4.我擅長制定編碼規範,大家聽個人就行了。oop

    反駁:若是須要制定編碼規範應該民主制定,至少得知足大多數人的需求和接受範圍測試

二. 代碼複審

General

Does the code work? Does it perform its intended function, the logic is correct etc.

代碼並無徹底完善,生成功能和計算功能實現可是仍有缺陷,檢驗和查重功能未開發。

Is all the code easily understood?

代碼風格清晰,雖然並非十分規範可是容易理解,關鍵地方有充分的註釋

Does it conform to your agreed coding conventions? These will usually cover location of braces, variable and function names, line length, indentations, formatting, and comments.

十分規範,大括號另起一行以及留空格習慣使代碼看起來格式賞心悅目,變量名多而準確

Is there any redundant or duplicate code?

有一些地方能夠簡化合並一下

Is the code as modular as possible?

採用C編寫,並無採用面相對象程序設計,並無模塊化,可是並不十分影響理解

Can any global variables be replaced?

全局變量少,一些用來傳遞的參數能夠設置爲全局的

Is there any commented out code?

有被註釋掉的代碼

Do loops have a set length and correct termination conditions?

是的

Can any of the code be replaced with library functions?

能用到庫函數的都用到了

Can any logging or debugging code be removed?

有的被註釋到了

Security

Are all data inputs checked (for the correct type, length, format, and range) and encoded?

沒有

Where third-party utilities are used, are returning errors being caught?

沒有

Are output values checked and encoded?

沒有,存在生成的真分數分母爲0的狀況沒有處理

Are invalid parameter values handled?

沒有

Documentation

Do comments exist and describe the intent of the code?

沒有寫文檔

Are all functions commented?

沒有寫文檔

Is any unusual behavior or edge-case handling described?

沒有寫文檔

Is the use and function of third-party libraries documented?

沒有寫文檔

Are data structures and units of measurement explained?

沒有寫文檔

Is there any incomplete code? If so, should it be removed or flagged with a suitable marker like ‘TODO’?

沒有寫文檔

Testing

Is the code testable? i.e. don’t add too many or hide dependencies, unable to initialize objects, test frameworks can use methods etc.

程序並不能經得起測試

Do tests exist and are they comprehensive? i.e. has at least your agreed on code coverage.

程序中沒有包含測試用例

Do unit tests actually test that the code is performing the intended functionality?

程序中沒有包含unit tests,須要人工測試

Are arrays checked for ‘out-of-bound’ errors?

數據結構多使用數組,所有設定在數組範圍內並無出現out-of-bound

Could any test code be replaced with the use of an existing API?

程序中沒有包含test code

相關文章
相關標籤/搜索