> For the complete documentation index, see [llms.txt](https://cs61b-2.gitbook.io/cs61b-textbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cs61b-2.gitbook.io/cs61b-textbook/10.-inheritance-ii-extends-casting-higher-order-functions/10.2-encapsulation.md).

# 10.2 Encapsulation

### Complexity

When building large programs, our enemy is complexity.

Some tools for managing complexity:

* Hierarchical abstraction.
  * Create layers of abstraction, with clear abstraction barriers!
* “Design for change” (D. Parnas)
  * Organize program around objects.
  * Let objects decide how things are done.
  * Hide information others don’t need.

Managing complexity is super important for large projects!

### Modules and Encapsulation

**Module:** A set of methods that work together as a whole to perform some task or set of related tasks. A module is said to be **encapsulated** if its implementation is completely hidden, and it can be accessed only through a documented interface.
