Comparison
Information hidingvsModule pattern
Information hiding
the thing most likely to change is the only thing behind the interface, and nobody outside can name it.
Parnas's original criterion for decomposing a system: each module hides one decision that is likely to change, so the change stays inside it. It predates encapsulation as a language feature and is a stronger idea than it — private fields hide data, information hiding hides a decision. The test is not whether the fields are private but whether you could change the decision without editing anything outside the module.
Full entry →Module pattern
everything is inside one function that returns an object with three methods, and the rest is unreachable from outside.
Wrapping state and functions in a scope and exposing only a chosen surface, giving private members in a language that has no private keyword. It is how encapsulation was done in JavaScript before modules and classes and remains a common shape in plugin and library code. It is worth naming because it is a reminder that encapsulation is a design property, not a language feature.
Full entry →