Low coupling between modules and high cohesion inside each module are the k
ey features of good software design. This is obtained by encapsulating the
details about the internal structure of data and exporting only public func
tions with a clean interface. The only native support to encapsulation offe
red by procedural programming languages, such as C, is the possibility to l
imit the visibility of entities at the file level. Thus, modular decomposit
ion is achieved by assigning functions and data structures to different fil
es. This paper proposes a new approach to using concept analysis for module
restructuring, based on the computation of extended concept subpartitions.
Alternative modularizations, characterized by high cohesion around the int
ernal structures that are being manipulated, can be determined by such a me
thod. To assess the quality of the restructured modules, the trade-off betw
een encapsulation violations and decomposition is considered and proper mea
sures for both factors are defined. Furthermore, the cost of restructuring
is evaluated through a measure of distance between original and new modular
izations. Concept subpartitions were determined for a test suite of 20 prog
rams of variable size, 10 public domain and 10 industrial applications. On
the resulting module candidates, the trade-off between encapsulation and de
composition was measured, together with an estimate of the cost of restruct
uring. Moreover, the ability of concept analysis to determine meaningful mo
dularizations was assessed in two ways. First, programs without encapsulati
on violations were used as oracles, assuming the absence of violations as a
n indicator of careful decomposition. Second, the suggested restructuring i
nterventions were actually implemented in some case studies to evaluate the
feasibility of restructuring and to deeply investigate the code organizati
on before and aft:er the intervention. Concept analysis was experienced to
be a powerful tool supporting module restructuring.