如何提升軟體品質?

從紀律做起)

紀律
Discipline

紀律一, follow 公司規定的 Coding Conventions

方法:

靠 IDE 自動提醒你 Conventions 錯誤與否!!

存檔時,

記得要(自動) Formatting 你的程式碼

平常(盡量自動),

利用程式語言的 linter 來檢查你的程式碼

什麼是 coding conventions?

 

也有人叫它 coding style, coding standards

 

利用 Formatting + Linting 來輔助你, 

也用相同的設定, 讓公司或 team 的規範一致與大家的程式碼結果相同

 

如果公司沒有硬性規定, follow 標準的就好

舉例

indentation (跳幾個空白)

docstrings  (註解的寫法) ->

Google style

numpy docstrings

 style

紀律二, 寫 Unit-tests

方法:

Unit-tests 通過, 才可以 git commit your code

(自動)CI/CD 才有意義

(先用 Travis.ci)

Travis.CI + github.com

紀律三, 寫好文件

目的:

讓你的 code more readable, and easy to use!!

(而且, 可以同時產生出 Python docs, 用   Sphinx)

 

How to Writing Docstrings -> here

Sphinx + napoleon (extension)

語言與習慣

挑對語言, 或改善寫法 -> 決定品質

例如: Javascript -> Typescript (強制寫明 變數或回傳值的 types)

例如: C++ -> Rust  (避免 null pointers, 造成 crash)

例如: Python (使用 3.5 以上, 用 typing 寫法) -> mypy (範例)

如何提升軟體品質?- 從紀律做起

By Ming-der Wang

如何提升軟體品質?- 從紀律做起

  • 920