Years of programming experience has convinced us that the physical structur
e of a program, such as the locations of the program's components, their ca
lls, and the depth of nested calls, is important in determining how effecti
ve and efficient the program can be debugged and maintained. This paper int
roduces a new class of physical metrics, known as locality metric, that mea
sures the relative positions of components in a program listing and reveals
useful attributes that may affect programmer productivity. The placement o
f the components can be determined by a simple algorithm that is of polynom
ial time complexity. The paper compares the performance of the algorithm wi
th that of an exhaustive search approach and also reports various character
istics of the locality metric based on the collected statistical data. The
performance shows the feasibility of the algorithm and closeness of its out
put to the optimal result found by the exhaustive approach. (C) 2000 Elsevi
er Science Inc. All rights reserved.