The Impact of Mutability on Cyclomatic Complexity in Java
Marat Bagaev, Alisa Khabibrakhmanova, Georgy Sabaev, Yegor Bugayenko

TL;DR
This study investigates how mutability of object attributes in Java influences cyclomatic complexity, finding that immutable objects are significantly less complex than mutable ones, which could improve code maintainability.
Contribution
The paper provides empirical evidence linking object mutability to cyclomatic complexity in Java, highlighting the benefits of using immutable classes.
Findings
Immutable objects are nearly three times less complex than mutable ones.
Using more immutable classes can reduce overall code complexity.
Mutability significantly impacts code maintainability.
Abstract
In Java, some object attributes are mutable, while others are immutable (with the "final" modifier attached to them). Objects that have at least one mutable attribute may be referred to as "mutable" objects. We suspect that mutable objects have higher McCabe's Cyclomatic Complexity (CC) than immutable ones. To validate this intuition, we analysed 862,446 Java files from 1,000 open-GitHub repositories. Our results demonstrated that immutable objects are almost three times less complex than mutable ones. It can be therefore assumed that using more immutable classes could reduce the overall complexity and maintainability of the code base.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Artificial Intelligence in Games · Advanced Malware Detection Techniques
