David C. Wyld et al. (Eds) : CSEN, AISO, NCWC, SIPR - 2015
pp. 01–10, 2015. © CS & IT-CSCP 2015 DOI : 10.5121/csit.2015.51401
Ron Coleman and Pritesh Gandhi
Computer Science Department, Marist College, Poughkeepsie, New York, USA
roncoleman@marist.edu pritesh.gandhi1@marist.edu
ABSTRACT
This paper studies a new, quantitative approach using fractal geometry to analyse basic tenets
of good programming style. Experiments on C source of the GNU/Linux Core Utilities, a
collection of 114 programs or approximately 70,000 lines of code, show systematic changes in
style are correlated with statistically significant changes in fractal dimension (P0.0009). The
data further show positive but weak correlation between lines of code and fractal dimension
(r=0.0878). These results suggest the fractal dimension is a reliable metric of changes that
affect good style, the knowledge of which may be useful for maintaining a code base.
KEYWORDS
Good programming style, fractal dimension, GNU/Linux Core Utilities
1. INTRODUCTION
Good programming style is a way of writing source code. Although different style guides have
different conventions, a survey of contemporary texts [1] [2] [3] [4] finds general agreement on
three basic rules: use proper indentation, include documentation, and choose meaningful or
mnemonic names. While style guides stress the importance of good style, especially for
maintenance purposes, “good” is a value word and “style” connotes, among other things, form
and taste. In other words, we propose source has potential elegance as a work of art like a
painting or photograph and indeed, any given programming style, including an indecorous one,
may be readily accessible without an in-depth understanding of how the code works or even what
it does. In this view, source has aesthetic or sensori-emotional qualities.
We are not suggesting aesthetic appeal in code should be an overarching goal of software, only
that it plays a role in crafting and maintaining code as a best practice. Yet aesthetics present
challenges. According to a modernist, Kantian view [5], aesthetics in general and notions of
beauty and matters of taste in particular are thought to be subjective, relative, and presumably
beyond the pale of automation. However, software engineers have sidestepped these dilemmas,
asking not what is beauty in source but rather what is knowable about such beauty (e.g., good
programming style), which can be incorporated in programs like the GNU/Linux command,
indent [6], which beautifies C source by refactoring indentation, comments, and spacing. Tools
like indent are a staple of modern software engineering. Unfortunately, these tools do not
quantify the value of their beautifying regimes, as a consequence developers have had to resort to