Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

uml - Code understanding, reverse engineering, best concepts and tools. Java

One of most demanding tasks for any programmer, architect is understanding other's code.

For example, I am contractor, hired to rescue some project very quickly. Fix bugs, plan global refactoring and therefore I need most efficient way to understand the code. What is the list of concepts, their priority and best tools for this?

Of what I know: reverse code engineering to create object models (creating of diagram per package is not so convenient), create sequence diagrams (the tool connects in debug mode to the system and generates diagrams from runtime). Some visualizing techniques, using some tools to work not just with .java but also with e.g. JPA implementors like Hibernate. Generate diagram for not all the codebase, but add some class and then classes used by it.

Is Sparx Enterprise Architect state of the art in reverse engineering or far from that? Any other better tools? Ideally would be that tool makes me understand the code as if I wrote it myself :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The book Object-Oriented Reengineering Patterns deals with this in detail. Unfortunately there is no silver bullet attached :-)

However, it lists a lot of useful techniques for taking over legacy code. In brief

  • 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...