Main Content

Monitor the Complexity of Your Design Using the Model Maintainability Dashboard

The Model Maintainability Dashboard collects metric data from the model design artifacts in a project to help you assess the size, architecture, and complexity of your design.

The dashboard analyzes different aspects of model maintainability from model design artifacts like Simulink® models, Stateflow® charts, and MATLAB® code. The model maintainability metrics help you determine if parts of a design are too complex and need to be refactored. A less complex design is easier to read, maintain, and test.

This example shows how to collect and explore the maintainability metric data for a project. As you update and development your design artifacts, use the dashboard to assess the impact on complexity and maintainability.

Open the Model Maintainability Dashboard for a Project

1. Open a project that contains design artifacts. For this example, in the MATLAB Command Window, enter:

openProject("cc_CruiseControl");

The project includes several models, tests, and requirements files.

2. The Model Maintainability Dashboard is a model design dashboard that displays maintainability metrics. To open the Model Maintainability Dashboard, use one of these approaches:

  • On the Project tab, in the Tools section, click Model Design Dashboard.

  • Open a model in the project and, in the Apps gallery, click Model Design Dashboard.

  • In the Command Window, enter:

modelDesignDashboard

The dashboard app launches and opens a new Model Maintainability tab for the software component cc_CruiseControl.

Explore the Project Architecture

On the left side of the dashboard app is the Project panel which displays the architecture of the units and components in the current project. You can use the Project panel to open the dashboard for the different units and components in your project architecture. Software components use the Component icon and software units use the Unit icon .

3. In the Project panel, expand the component cc_CruiseControl. The component cc_CruiseControl contains 4 software units: cc_ControlMode, cc_DriverSwRequest, cc_LightControl, and cc_ThrottleController.

4. Select the unit cc_ControlMode to open a Model Maintainability Dashboard for that software unit. If a dashboard is not available for a specific unit or component, the name of the unit or component appears dimmed.

The Model Maintainability Dashboard shows metric results for the size, architecture, and complexity of the unit.

Explore the Design Artifacts

On the bottom left of the dashboard app is the Artifacts panel which displays the artifacts inside the selected unit or component. The Functional Requirements, Design, Tests, and Test Results folders contain the artifacts the dashboard traced to the current unit or component.

For example, when cc_ControlMode is selected in the Project panel, the Artifacts panel displays the artifacts associated with the unit cc_ControlMode.

5. In the Artifacts panel, expand the Design folder. For the unit cc_ControlMode, the Design folder shows the associated data dictionary, model, and subsystem references.

In the toolstrip for the dashboard app, you can click the Legend button to view a list of the icons for artifacts that the dashboard traces.

Explore the Maintainability Metrics

When you open a Model Maintainability Dashboard, the dashboard automatically collects the metric data and displays the results in the six main sections of the dashboard:

  • Component Structure

  • Component Interface

  • Design Cyclomatic Complexity Breakdown

  • Halstead Difficulty Breakdown

  • Simulink Architecture

  • Stateflow Architecture

  • MATLAB Architecture

Each section of the dashboard contains widgets that help you interact with the metric data.

6. In the Component Structure section of the dashboard, point to the Complexity widget. Three dots appears in the top-right corner of the widget.

Point to the three dots and click the Help icon to view more information about the metric and how the dashboard calculates the metric value.

7. In the Simulink Architecture section, in the Signal Lines row and Distribution column, the metric results show an outlier in the signal line distribution.

The dashboard sorted most of the metric data into the three distribution bins on the left. The rightmost distribution bin contains metric data that is outside of that range.

8. Point to the rightmost distribution bin. The tooltip indicates that there is one layer in the model hierarchy containing between 60 and 69 Simulink signals.

The other layers of the model contain fewer signal lines. For example, the leftmost distribution bin shows nine model layers containing fewer than 10 Simulink signals.

9. Click the rightmost distribution bin to explore the metric data in more detail.

The dashboard opens the Metric Details for the widget with a table of metric values and hyperlinks to each related artifact. The table shows that the artifact Control_Mode_StateMachine contains 60 signal lines.

Note that there is a breadcrumb trail from the Metric Details back to the main Model Maintainability results for cc_ControlMode.

10. In the Artifact column, click on Control_Mode_StateMachine to open the artifact in Simulink.

In this example, the artifact Control_Mode_StateMachine is a subsystem in the model cc_ControlMode. If the 60 signal lines at the top layer of the subsystem make the design hard to read, refactor the model layer to improve readability.

See Also

Related Topics