Modularity is an important concept in evolutionary theorizing but lack of a consistent definition renders study difficult. Using the generalized NK-model of fitness landscapes, we differentiate modularity from decomposability. Modular and decomposable systems are both composed of subsystems, but in the former, these subsystems are connected via interface standards, while in the latter, subsystems are completely isolated. We derive the optimal level of modularity, which minimizes the time required to globally optimize a system, both for the case of two-layered systems and for the general case of multi-layered hierarchical systems containing modules within modules. This derivation supports the hypothesis of modularity as a mechanism to increase the speed of evolution. Our formal definition clarifies the concept of modularity and provides a framework and an analytical baseline for further research.