Skip to content

Is there a metric for "architectural complexity"? #62

@skytreader

Description

@skytreader

Hello. This is the question I wanted to ask originally before I ran into issue #59. Though I fear is more about the state of the art than this project exclusively, I also want to hear your opinion on whether the project's current parsing can already measure for this (that is, we have the data structures but we lack the algorithm, maybe).

So can the framework measure "architectural complexity" especially with respect to module coupling? The use-case for this is best illustrated by the aforementioned FizzBuzzEnterpriseEdition. The tool ranks its cognitive complexity as follows: 92.4% low, 5.5% medium, 2.1% high. Those are enviable numbers.

And yet that does not reflect the fact that FizzBuzz EE is over-engineered and hardly a good example of software architecture. On personal introspection, the problem is too much abstraction. On one hand this is probably the key to minimizing the cognitive complexity overall but on the other hand, this removes a lot of the code from surrounding context that, on any real-world problem domain, it's hard to see how all of it comes together.

Based on experience, this also affects the testability of the code: it's easy to verify that each individual module conforms to its contract but it's hard to verify that it all fits together properly. Even with 100% coverage, at the top of the abstraction tree you can still be blindsided by a subtle change/edge case one of your dependencies introduced.

Unfortunately I haven't found a study for this metric yet, so I can't suggest an established concept to follow. In fact, the only significant mention I can find of this in my own research is in this blog entry:

Coupling is the connection between one piece of code and another. Keep it to a minimum. If a problem arises with one piece, you’ll need to adjust each piece that’s coupled to it. A developer can fall down the rabbit hole trying to find out which coupled function didn’t get updated.

So what do you think about this? Can the current AST parsing handle this? Is it even possible for plain static code analysis to achieve this? Personally, it would suit my use cases if this is possible with TS but maybe for weaker type systems this would be impossible.

(I'm thinking one ad-hoc way to do this would be to find the depth of the abstraction/dependency tree, but I already foresee some pitfalls with this approach, e.g., if there are unused imports, if there are untyped variables, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions