- Modern Programming: Object Oriented Programming and Best Practices
- Graham Lee
- 285字
- 2021-05-21 22:06:04
Static Analysis
In the Chapter 5, Coding Practices, there's a section on Code Reviews. Knowing that reviewers will find and fixate upon the simplest problems they can find, wouldn't it be great to remove all the trivial problems so that they're forced to look for something more substantial?
This is what static analysis does. It finds problems in code that can be automatically discovered without running the product, but that are either off-topic for compiler warnings or take too long to discover for the compiler to be an appropriate tool to search for them.
What are off-topic problems? Typically, those that require knowledge of the semantics of the functions or methods you're using – knowledge that's beyond the scope of the compiler. For example, consider a C++ destroyObject<T>(T t) function that deletes its parameter. Calling that function twice with the same argument would be an error – but the compiler doesn't know that if it's just inspecting the function signature. Others are a matter of style. For example, Apple's C APIs have a naming convention related to their memory management rules: a function name contains Create when the caller owns the returned object or Get when the callee does. It's not a mistake to use C language to mix those up, so the compiler won't tell you about it, but an analyzer can.
There is basically no reason to avoid using a static analyzer (if your reason is that there isn't one for your language/framework/whatever yet, you might have chosen a language/framework/whatever that isn't ready yet. There's a section about that in Chapter 12, Business). It'll discover easily fixable bugs for you and quickly train you into not making those mistakes in the first place.
- 有趣的二進制:軟件安全與逆向分析
- 從零開始學(xué)Hadoop大數(shù)據(jù)分析(視頻教學(xué)版)
- DB29forLinux,UNIX,Windows數(shù)據(jù)庫管理認證指南
- PySpark大數(shù)據(jù)分析與應(yīng)用
- 數(shù)亦有道:Python數(shù)據(jù)科學(xué)指南
- Spark大數(shù)據(jù)分析實戰(zhàn)
- 跟老男孩學(xué)Linux運維:MySQL入門與提高實踐
- gnuplot Cookbook
- Flutter Projects
- SQL Server 2012數(shù)據(jù)庫管理教程
- 淘寶、天貓電商數(shù)據(jù)分析與挖掘?qū)崙?zhàn)(第2版)
- 聯(lián)動Oracle:設(shè)計思想、架構(gòu)實現(xiàn)與AWR報告
- 數(shù)據(jù)庫查詢優(yōu)化器的藝術(shù):原理解析與SQL性能優(yōu)化
- MySQL數(shù)據(jù)庫實用教程
- 云原生架構(gòu):從技術(shù)演進到最佳實踐