Chapter 13. Interactive Restructuring and Code Organization

Sonargraph offers the concept of the architectural view to enable:

  • Interactive restructuring a software system via refactorings.

  • Interactive organization of a software system via architecture artifacts. Components (physical) or top-level programming elements (logical) are assigned to those artifacts based on the package, namespace or directory structure or based on an architectural pattern language overcoming structural constraints.

  • Generation of architecture DSL files that can be automatically checked.

  • Generation of refactoring lists that are applied to the "production" modifiable (virtual) model.

An Architectural view is an Exploration view with architecture modeling capabilities (see Section 8.11.1, “ Exploration View ”). An Architectural view is created using a specific structure mode and by applying operations to it. It is created based on the currently loaded (parsed) system after applying the selected virtual model. Multiple architectural views can be defined that are each persisted in an individual file.

  • Creation of an architectural view which is persisted in a file. Use menu "File""New""Architectural View""New Architectural View..." or right-click in the Files view on the Architectural Views node and use the corresponding context menu entry. Choose between 4 model structures (physical with or physical without root directories, logical system or logical module scope) when creating an architectural view. An existing architectural view can be opened from the files view via the context menu or via double-click. Both "create" and "open" interactions require a loaded parser model.

  • The architectural view shows a tree-like structure down to component level (physical) or top-level programming element (logical).

  • Selection support by pressing SHIFT in combination with the arrow keys (up and down) or left mouse click for bulk selection. Use the modifier key (CMD, CTRL) of your operating system in combination with left mouse-click to add or remove elements to/from the current selection.

  • Artifacts with their properties can be created either based on a selection or empty. Try the context menu on selections (right mouse click) to see what is possible. F2 allows editing 1 or multiple artifacts.

  • Assign/remove elements to/from existing artifacts via drag and drop.

  • Change parent/child structures of artifacts via drag and drop.

  • Assign components (physical) or top-level programming elements (logical) to artifacts with manual filter definition using patterns. All assignment strategies from the architecture DSL are supported, see Section 11.1, “ Models, Components and Artifacts ” and following chapters.

  • Define explicitly allowed artifact connections.

  • Hide non-artifact/non-module nodes in their corresponding artifacts to make them unaccessible.

  • Apply delete refactorings to non-artifact/non-module nodes.

  • Apply delete refactorings to dependencies.

  • Apply move refactorings to components (physical) or top-level programming elements (logical).

  • Apply rename refactorings to non-artifact/non-module nodes.

  • Use focus operations to visualize only certain elements of the Architectural view.

  • Create packages, namespaces or directories when needed as targets for move refactorings.

  • Create 'Findings' based on dependencies. Those findings appear in a list, have a name an optional description. Optionally dependencies violating the architecture contained in a finding can be ignored. It is also possible to apply focus operations based on findings.

  • The operations you apply (e.g. create/edit artifacts, move elements, delete elements ...) may be seen in the operations view. The operations may also be deleted from that list using the context menu. Operations that have no effect (e.g. a previous element is no longer their because the code changed) are marked with a warning marker.

  • The architecture is checked in real-time meaning that you see the dependencies changing their colors according to their violation state when applying operations.

  • Undo/redo of operations.

  • Forward/backward navigation.

  • Export what you see into images files on disk.

  • Generation of an architecture DSL file based on the model defined in the architectural view.

  • Export of resulting refactorings into an Excel file.

  • Export of resulting violations into an Excel file.

  • The views Properties, Parser Dependencies (Out) and Parser Dependencies (In) react to the selection in the Architectural view and show the corresponding additional information of the selected element.

Levelization Mode and Operations

Since the Architectural view is designed to create architecture aspects it always shows the levelization mode widget (see Section 8.11.1.1, “Levelization”). Architectural view operations can only be applied when the levelization mode is set to 'Non Artifacts Only' since the artifacts are not shown in their definition order.