Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
strauss_d_getting_started_with_visual_studio_2022_learning_a.pdf
Скачиваний:
123
Добавлен:
26.06.2023
Размер:
17.04 Mб
Скачать

Chapter 2 Working with Visual Studio 2022

Code Metrics Results

The project we have been using in this chapter is really not complex. It is just to illustrate the concepts in this book. If you take a more complex project, one of the projects you have worked on at work, this next screen looks a lot different.

Code Metrics Results (Figure 2-77) is a set of measurements that allow developers to gain a better insight into the code they produce.

Figure 2-77.  Code Metrics Results

The image in Figure 2-77 results from the ShipmentLocator application we have used throughout this chapter. It’s not a complex application; therefore, the metrics might all seem fine.

Please note that it will be blank when you first open the Code Metrics Results screen. You need to click the Calculate Code Metrics for Solution button in the topleft corner of the window.

Looking at the same screen (Figure 2-78) for a more complex project (one of my old legacy projects), the metrics are pretty different.

153

Chapter 2 Working with Visual Studio 2022

Figure 2-78.  Code Metrics Results on a large project

Each metric in the window refers to specific software measurements. These are the code metrics that Visual Studio calculates:

•\

Maintainability Index

•\

Cyclomatic Complexity

•\

Depth of Inheritance

•\

Class Coupling

•\

Lines of Code

These metrics allow developers to understand what portions of code need to be refactored or more rigorously tested. It also allows developers to identify potential risks in their software. Ratings in this window are also color-coded so developers can quickly identify trouble spots.

Maintainability Index

The maintainability index represents a value between 0 and 100, illustrating how easy it is to maintain the code. The higher the value, the more maintainable your code is.

154