0

使用 McCabe 公式时

M = EN + 2C

是否考虑到数据是否仅限于一个方向流动?图表似乎显示了数据在多个方向上的流动,不管这是否真的发生了。

具有一个数据流方向的代码库与另一个(非常相似的)数据可以来回传输的代码库将不那么复杂。

这篇关于 Facebook、MVC 和 Flux 的文章是我所问问题的一个很好的例子:http: //www.infoq.com/news/2014/05/facebook-mvc-flux。他们最初使用 MVC 来回传数据(从视图到模型,反之亦然)。一旦将 MVC 切换为 Flux,数据就会朝一个方向流动。

4

1 回答 1

1

The article you linked to was about replacing one (misapplied) architectural pattern with another.
The concept of "data flow" is not well defined, but doesn't matter to the question.

The McCabe formula examines program flow - very informally you could see it as a measure of the number of decisions made. But this is measured by looking at every control statement, so the scale of what it measures is much finer grained than the scale of the architectural changes you propose.

Let's go with "the McCabe formula doesn't measure data flow".

If you make the breadth of changes required to redesign an architecture, then the formula will of course produce a different result. Based on the branching factor of the program, as always.

Suppose you redesign a program so that code - and specifically decisions - are repeated less often. Then the complexity could well go down. You may also judge this to be a better architecture.

But cyclomatic complexity isn't a way of describing anything as large as architecture really. It is a way of looking at small chunks of code; methods, classes. Using it to evaluate architecture is pretty meaningless, as any architecture could be implemented well or badly.

于 2014-05-18T17:05:45.887 回答