一千萬個為什麽

搜索

代碼理解,逆向工程,最佳概念和工具。 Java的

對於任何程序員來說,架構師都是最苛刻的任務之一,他們正在理解其他代碼。

例如,我是承包商,雇用很快就救出一些項目。修復錯誤,計劃全局重構,因此我需要最有效的方法來理解代碼。什麽是概念列表,它們的優先級和最佳工具?

據我所知:用於創建對象模型的逆向代碼工程(每個包創建圖表不太方便),創建序列圖(該工具以調試模式連接到系統並從運行時生成圖表)。一些可視化技術,使用一些工具不僅可以使用 .java ,還可以使用一些工具。 JPA 實現者,如 Hibernate 。為所有代碼庫生成圖表,但添加一些類,然後添加它使用的類。

Sparx Enterprise Architect是逆向工程還是最先進的技術還是遠遠不夠?還有其他更好的工具?理想情況下,該工具會讓我理解代碼,就好像我自己編寫的那樣:)

最佳答案

面向對象的重新設計模式這本書詳細介紹了這一點。不幸的是沒有附上銀彈:-)

但是,它列出了許多用於接管遺留代碼的有用技術。簡單來說

  • interview at least some of the original developers (if they are still around) about
    • development history: phases, releases
    • current state of affairs
    • team social structure, politics, dynamics: when and why did people join and leave
    • bugs: typical, easiest, hardest
    • code quality: cleanest/ugliest parts
    • configuration data: form, content and usage
    • unit/integration/manual/... test cases and data
    • SCM branch structure and usage
    • documentation: what is documented where, is it up to date
    • contact persons for external interfaces
  • Watch developers/users during demo to find
    • main features
    • typical use cases
    • usage anecdotes
    • good/bad, missing/superfluous functionality
  • "read all the code in one hour"
    • get high level view of class hierarchies, interfaces
    • take multiple sessions if needed
    • identify large structures (these often contain important functionality)
    • look for design patterns
    • check comments (they can reveal a lot, but may be also misleading)
  • skim documentation (if there is any)
    • just record the availability of specific types of docs e.g. specification, UML diagram, Wiki, Javadoc etc.
    • is it useful and why (not)
    • is it up to date

轉載註明原文: 代碼理解,逆向工程,最佳概念和工具。 Java的