Abstraction represents functionality at a higher level by giving a useful name to a package of behavior while setting lower-level details aside. Functions reduce repetition and let programs be reasoned about in terms of meaningful actions rather than every operation involved. section 7.0
Use abstraction to make code easier to understand, change, and extend:
- Wrap repeated behavior in a function and call it by name instead of duplicating its implementation. section 7.0
- Define objects and classes around distinct responsibilities, allowing code to use a concise interface without depending on internal implementation. section 10.2
- Preserve an interface while changing the implementation, such as revising how an average is calculated without changing how callers use it. section 10.2
- Treat functions as data when useful: store them in data structures, retrieve them, and use them to reduce code and increase flexibility. section 7.0
A bookshelf as an abstraction
Saying “bookshelf” communicates a concept more briefly and powerfully than describing wooden boards, fasteners, orientation, and storage spaces. A class provides the same kind of shorthand for program concepts: users focus on its methods and behavior rather than its internal construction. section 10.2














