如何可视化大型代码库质量的变化?

发布于 2024-09-26 03:09:03 字数 1299 浏览 0 评论 0 原文

我经常思考的一件事是我们如何使用某种指标来衡量变化,我们是否会倒退?这是在我们正在改进的大型遗留代码库的背景下进行的。大部分代码是具有 C 传统的 C++。一些新函数和 GUI 是用 C# 编写的。

首先,我们至少可以检查代码中的简单复杂性级别是否随着时间的推移而变化。困难在于有一个表示——我们也许可以做一个 3D 表面,其中 2D 地图代表代码,我们有一个代表复杂性的颜色热图,3D 表面凸出和凸出以显示变化。

一旦你可以生成一些数字矩阵,就会有大量的数学系统来处理这样的事情。

随着时间的推移,我希望其中有更复杂的数字,但使用相同的可视化技术来表示变化。

我喜欢 Crap4j 中关注复杂性和覆盖该代码的单元测试数量。

我还想包括 Uncle Bob 的 SOLID 指标 以及一些 Chidamber 和 Kemerer OO 指标。困难的部分是找到为 C++ 生成这些的工具。唯一的选择似乎是Krakatau Essential Metrics(我不反对为工具付费)。我使用 CK 指标的愿望部分来自于书籍面向对象的指标:复杂性的度量 由 Henderson-Sellers 和早期的面向对象的软件指标

如果我们开始使用其中一些指标,我们最终可能会得到十个左右的数字,这些数字会随着时间的推移而变化。我对统计数据相当无知,但跟踪一堆这样的指标,然后注意哪些指标往往会变化似乎很有趣。

请注意,一个相关的问题是关于测量整个项目的代码质量庞大的代码库。我对衡量变化更感兴趣。

One of the things I’ve been thinking about a lot off and on is how we can use metrics of some kind to measure change, are we going backwards or not? This is in the context of a large, legacy code base which we are improving. Most of the code is C++ with a C heritage. Some new functions and the GUI are written in C#.

To start with, we could at least be checking if the simple complexity level was changing over time in the code. The difficulty is in having a representation – we can maybe do a 3D surface where a 2D map represents the code and we have a heat-map of color representing complexity with the 3D surface bulging in and out to show change.

Once you can generate some matrics of numbers there are a ton of math systems around to take care of stuff like this.

Over time, I'd like to have more sophisticated numbers in there but the same visualisation techniques used to represent change.

I like the idea in Crap4j of focusing on the ratio between complexity and number of unit tests covering that code.

I'd also like to include Uncle Bob's SOLID metrics and some of the Chidamber and Kemerer OO metrics. The hard part is finding tools to generate these for C++. The only option seems to be Krakatau Essential Metrics (I have no objection to paying for tools). My desire to use the CK metrics comes partly from the books Object-Oriented Metrics:Measures of Complexity by Henderson-Sellers and the earlier Object-Oriented Software Metrics.

If we start using a number of these metrics we could end up with ten or so numbers that are varying across time. I'm fairly ignorant of statistics but it seems it could be interesting to track a bunch of such metrics and then pay attention to which ones tend to vary.

Note that a related question is about measuring code quality across a large code base. I'm more interested in measuring the change.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灯下孤影 2024-10-03 03:09:03

我会考虑使用 Kiviat 图 来表示随时间演变的多个软件指标维度。这些图表示中心点周围凹壳中的多个数据点。目视检查将显示特定指标的上升或下降位置,并且应该能够使用某种色调面积计算来计算由指标值偏差的总体面积比率。

I'd consider using a Kiviat Diagram to represent multiple software metrics dimensions evolving over time. These diagrams represent multiple data points in a concave hull around a centerpoint. Visual inspection will show where a particular metric is going up or down, and one ought to be able to compute an overall ratio of area biased by metric value using some hueristic area computation.

随波逐流 2024-10-03 03:09:03

您还可以查看有关代码指标的 NDepend 文档免责声明:我是 NDepend 工具的开发人员之一。

使用 通过 LINQ 的代码规则和查询 (CQLinq) 工具,可以请求代码库的两个不同快照之间的代码度量演变/趋势。例如,建议使用默认规则: 避免使复杂方法均匀更复杂如下面的屏幕截图所示:

避免使复杂的方法变得更加复杂

提出了几种指标趋势规则,例如:

关于代码指标的可视化,NDepend 让代码指标值通过交互式树形图可视化:

通过树状图可视化的代码指标

You can also have a glance at NDepend documentation about code metrics. Disclaimer: I am one of the developer of the tool NDepend.

With the Code Rule and Query over LINQ (CQLinq) facility, it is possible to ask for code metric evolution/trending across two different snapshots in time of the code base. For example there is a default rule proposed: Avoid making complex methods even more complex illustrated by the screenshot below:

Avoid making complex methods even more complex

Several metric trending rules are proposed like:

Concerning the visualization of code metric, NDepend lets visualize code metrics values through an interactive treemap:

Code Metric viualized through Treemap

源来凯始玺欢你 2024-10-03 03:09:03

对于这个主题有一种新的方法。
例如
输入图片此处描述
https://github.com/databricks/koalas/pull/840#issuecomment- 536949320

请参阅https://softagram.com/docs/visualizing-code-changes / 了解更多信息或使用两个关键字在搜索引擎中进行图像搜索:softagram koalas

免责声明:我为 Softagram 工作。

There is a fresh approach for this topic.
E.g.
enter image description here
https://github.com/databricks/koalas/pull/840#issuecomment-536949320

See https://softagram.com/docs/visualizing-code-changes/ for more info or do an image search in search engine using the two keywords: softagram koalas

Disclaimer: I work for Softagram.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文