The vice-versa direction-source code to diagrams--is commonly referred to as reverse engineering.
Compiled Java code contains enough information that you can also reverse engineer from the compiled file back to diagrams as well.
Actual source code is not necessary. Most other languages, such as C++, are not so easy to reverse engineer.
Reverse engineering is the process of discovering the technological principles of a device, object, or system through analysis of its structure, function, and operation. It often involves disassembling something (computer program, chemical, or organic matter) and analyzing its components and workings in detail, just to re-create it. Reverse engineering is done for maintenance or to create a new device or program that does the same thing, without using the original.
The other reason Reverse engineering is carried out is to duplicate the original software.
Reverse engineering has its origins in the analysis of hardware for commercial or military advantage.
The purpose is to deduce design decisions from end products with little or no additional knowledge about the procedures involved in the original production. The same techniques are subsequently being researched for application to legacy software systems to replace incorrect, incomplete, or unavailable documentation.
The Use of Diagrams in Practice
The fact that the UML is a detailed specification does not mean that every aspect of it must be used at all times. In fact, a proper subset of this notation is sufficient to express the semantics of a large percentage of analysis and design issues. We will highlight this subset during our presentation of the notation in this chapter.
Why, then, bother with the detail beyond this subset? Quite simply, such detail is necessary to express certain important tactical decisions. Additionally, some detail exists in the infrastructure of the UML, of interest to tool vendors, which facilitates the creation of
forward-engineering and reverse-engineering tools. Such internal details enable the integration of front-end CASE tools that support this notation together with software development environments that focus on manipulating the products of the object-oriented programming language.