Visualization of Package Dependencies

These scripts identify implicit dependencies across packages, and help users to automatically add and update these dependency relationship on UML Package diagrams.

When reverse engineering existing source code into Enterprise Architect, there is an option to import dependency relationships based on operation return types and parameter types.  These dependencies are only shown between individual classes.  Some users however, wish to view implicit dependencies at the Package level, which Enterprise Architect does not generate by default.

The purpose of these scripts is to generate implicit dependencies at the package level based on the contents of the packages, and to assist with drawing a diagram to show these cross-package dependencies.

 

Configuring the scripts

In this example, we will take advantage of the new ability to call scripts directly from the Project Browser, introduced in Enterprise Architect 8.0.

  1. Open the scripting window (View | Scripting)
  2. Create a new script group
  3. Name the group "Project Browser"
  4. Set the group type to "Project Browser"
  5. Create a new VBScript under this group and name it "Synchronize Package Dependencies"
  6. Open this new script in the built-in editor and paste in the contents of the file VBS_SynchPackageDependencies.txt
  7. Save
  8. Create another new VBScript under this same group and name it "Synchronize Package Dependency Diagram"
  9. Open this new script in the built-in editor and paste in the contents of the file VBS_SynchPackageDependencyDiagram.txt
  10. Save

 

Using the scripts

With the scripts successfully added to your model, select the root package in the Project Browser from where you wish to generate your cross-package dependencies. To see the messages output by this script, make sure to open the Output window (View | System Output).

  1. Create a new Diagram of type 'Package' and open it (this diagram is where the dependencies will be drawn)
  2. Right-click on the context package in the Project Browser and select "Scripts | Synchronize Package Dependencies".  The Output window will inform you when the process has been completed and report how many new package dependencies have been found.
  3. Right-click on your context package in the Project Browser again and select "Scripts | Synchronize Package Dependency Diagram"
  4. Several packages should now appear on your open diagram, but will all be piled on top of one another.  We can now use EA's automatic diagram layout tools to organize these packages into a sensible layout.
  5. Open the Diagram Layout window ("View | Layout Tools")
  6. Select "Digraph" layout and click the "Apply Layout" button

These scripts can be executed again at any later time to update any changes in your cross-package dependencies that may have occurred since the original execution.  Dependency relationships are added and removed between packages as necessary by running the “Synchronize Package Dependencies” script, and running the “Synchronize Package Dependency Diagram” script again can automatically add/remove packages from the currently open package diagram to show the items that are now relevant.  If any items are added or removed from the diagram, you may need to run the automatic diagram layout tools again.

 

Package-dependency

 

 

This article contains content available for registered members only. You need to be logged in to view/download this content.

About the Author

Sparx Systems

Sparx Systems

Sparx Systems specializes in high performance and scalable visual modeling tools for the planning, design and construction of software intensive systems. A Contributing Member of the Object Management Group (OMG), Sparx Systems is committed to realizing the potential of model-driven development based on open standards. The company’s flagship product, Enterprise Architect, has received numerous accolades since its commercial release in August, 2000. Enterprise Architect is the design tool of choice for over 250,000 registered users world-wide.

Comments

  • I imported C# packages as source code, own package for each namespace. Then tried to get dependencies between packages but it didn't find any dependency: "55 Packages synchronized, 0 Dependencies Added, 0 Dependencies Removed." What kind of dependencies it requires? And does source code importing insert those dependencies?

  • Hi, I'm wondering if it's also possible to use these scripts in Enterprise Architect 7.5, cause it's the version that we are using right now.

    • The code has been written to take adivantage of Enterprise Architect 8 features (eg Script Groups). However, the code can be easily adapted to be used by the Automation Interface in 7.5.

  • There is a LayoutDiagramEx function available on the EA.Project interface which performs the equivalent of the "Layout Diagram" command in Enterprise Architect as seen on the following user guide page:
    http://www.sparxsystems.com/enterprise_architect_user_guide/modeling_fun...
    Other layout algorithms provided by the Layout Tools window are not currently available via automation. Layout of the objects on your diagram can also be performed more explicitly by looping through the contents of your diagram (i.e. using the Diagram.DiagramObjects) and setting the Top, Bottom, Left and Right attributes on the EA.DiagramObject references.

  • Hi there; I really apptreciate your helpful guidance here. I would like to know how i can write a VB script inside EA to layout my objects on a specific diagram. Please help me with that. Regards; Amir Basirat