Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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

Cyclomatic Complexity

This metric measures the structure of your code and how complex it is. It uses the number of code paths it finds that flow through the program to calculate this score. A higher number indicates a complex control flow and is, therefore, harder to test and maintain. The numbers displayed in Figures 2-77 and 2-78 are totaled for each project in the solution. Here, it makes sense to expand the hierarchy and drill down to the individual methods to see where the problem areas lie.

Depth ofInheritance

As the name suggests, this metric measures the number of classes inherited from each other. This goes all the way down to the base class. A high number indicates deep inheritance, which is bad. Any changes to a base class can break code further up in the derived classes. Here, you want to see a lower score.

Class Coupling

Class Coupling measures how many classes a single class uses. A high number is bad, and a low number is good. Class Coupling has been shown to predict software failures accurately. With a high coupling score, the maintenance and reusability of the class become difficult because it depends on too many other types.

Lines ofCode

The lines of code here are based on the count of the IL code. So this isn’t an accurate count of lines of code in the source file. Nevertheless, you will agree that a high count indicates that a lot is happening. Expanding the projects and viewing the code counts for individual methods allow you to see which methods are trying to do too much. A high line count indicates a method that is harder to maintain. Try to refactor these methods and simplify them.

Send Feedback

The Visual Studio team takes feedback seriously. So much so that it drives much of what they do to improve Visual Studio.

155