Comment by pdkl95
10 years ago
Complexity grows (a lot) faster than the number of parts. A module with n parts can have O(n^2) pairwise interactions, so the potential for bugs (and debugging costs) grows faster than code size.
Many features of high level languages are attempts to add modularity and thus break the complexity up into manageable pieces. Functions, classes with "private" features, UNIX-style[1] tools, and other types of modular programming are ways to separate local complexity from the global environment.
A complex module with many internal parts adds a lot of complexity to a program, but by restricting the interfaced we greatly reduce how much complexity is exposed to the parent environment. A simple interface with only a few parts can hide many more parts that would have otherwise been potential interactions with the global environment (bug/attack surface).
Even better, well defined interfaces allow the separate modules to be implemented and debugged separately. Which would you rather debug? One 1000-line program or 10 separate 100-line programs? While they are the same amount of code, smaller programs are much easier to understand[2].
[1] http://www.catb.org/esr/writings/taoup/html/ch01s06.html#id2...
[2] http://www.catb.org/esr/writings/taoup/html/ch01s06.html#id2...
TL;DR - "KISS: Keep It Simple, Stupid!"
IE, You want the complexity of extra code to be additive, not multiplicative.