A module is a functional unit that accepts inputs and produces outputs. Modularization is the process of putting things of interest into a module and minimizing dependencies upon external things outside the module. High cohesion and low coupling are well-known modularization principles.
Encapsulation puts things in a module and protects them by controlling the visibility of outsiders. Most object-oriented programming (OOP) languages support encapsulation through the language construct – class, a wrapper of primitive data types (properties) and codes (methods). Members in a class can be seen in public, isolated in private, or protected and shared by child classes only.