Using the Add Dependencies feature


Overview

Object dependencies in coding refer to the relationships where one object relies on another object to function properly. When Object A uses, calls, or requires Object B to complete its tasks, we say that Object A has a dependency on Object B. In the context of CAST Imaging, object dependencies refer to the relationships between various code elements that the CAST automatically discovers and visualizes:

Types of dependencies that CAST Imaging identifies

  • Direct dependencies occur (for example) when one class explicitly creates or calls another class.
  • Indirect dependencies happen when Object A depends on B, and B depends on C, making A indirectly dependent on C.

How can CAST Imaging help in this context?

When objects are heavily dependent on specific implementations, your code becomes rigid and hard to change. Testing becomes difficult because it is not possible to easily isolate components. Changes in one class can therefore cascade through multiple dependent classes. This is where being able to visualize these dependencies can help when you need to make changes.

How do I access the feature?

CAST Imaging provides access to object dependencies via a right-click contextual menu (available at object level):

Selecting a menu option will automatically add the matching dependent objects into the view:

  • Direct dependencies are shown with solid lines
  • Indirect dependencies are shown with dotted lines

Arrows indicate the direction of the link:

  • Incoming link types: inward arrow (<—)
  • Outgoing link types: outward arrow (—>)

Example

Right-clicking a SQL procedure reveals dependent objects that can be added to the view, both direct and indirect:

Using the Add all option, we can now see one indirect dependency (dashed line to a C# class) and two direct dependencies (solid lines to a SQL table and a C# method):

What about Advanced Add?

The Advanced Add menu option is primarily aimed at situations where there are significant number of dependent objects and displaying them all would create a confused and complex image. The option allows you to filter the objects and display only those you are interested in:

In the above example, there are 54 dependent objects. Clicking Advanced Add will display a list of all these objects. Choose the objects you are interested in via the tick boxes and the Display selected button:

Use the filters along the top to narrow down the matching objects:

alt text