An Empirical Study on Maintainable Method Size in Java
Shaiful Alam Chowdhury, Gias Uddin, Reid Holmes

TL;DR
This study analyzes a large dataset of Java methods to establish empirical guidelines, suggesting keeping methods under 24 lines and decomposing larger methods to reduce future maintenance effort.
Contribution
It provides the first systematic empirical evidence linking method size to maintenance effort and offers practical size guidelines for Java developers.
Findings
Methods under 24 lines are easier to maintain.
Decomposing large methods reduces maintenance effort.
Empirical size guidelines improve software maintainability.
Abstract
Code metrics have been widely used to estimate software maintenance effort. Metrics have generally been used to guide developer effort to reduce or avoid future maintenance burdens. Size is the simplest and most widely deployed metric. The size metric is pervasive because size correlates with many other common metrics (e.g., McCabe complexity, readability, etc.). Given the ease of computing a method's size, and the ubiquity of these metrics in industrial settings, it is surprising that no systematic study has been performed to provide developers with meaningful method size guidelines with respect to future maintenance effort. In this paper we examine the evolution of around 785K Java methods and show that developers should strive to keep their Java methods under 24 lines in length. Additionally, we show that decomposing larger methods to smaller methods also decreases overall…
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 · Open Source Software Innovations · Software System Performance and Reliability
