|
|
|
|
|
|
|
At the end of the last chapter, we introduced the concept of data abstraction, the separation of a data type's logical properties from its implementation. Data abstraction is important because it allows us to create data types not otherwise available in a programming language. Another benefit of data abstraction is the ability to produce off-the-shelf softwarepieces of software that can be used over and over again in different programs either by the creator of the software or by any programmer wishing to use them. |
|
|
|
|
|
|
|
|
The primary tool for practicing data abstraction is the abstract data type, introduced briefly in Chapter 12. In this chapter, we examine abstract data types in depth and introduce the C++ language feature designed expressly for creating abstract data types: the class. We conclude with two case studies that demonstrate data abstraction, abstract data types, and C++ classes. |
|
|
|
|
|
|
|
|
We live in a complex world. Throughout the course of each day, we are constantly bombarded with information, facts, and details. Most government and business operations, legal regulations, and technical products are too complicated for one person to understand thoroughly. To cope with complexity, the human mind engages in abstractionthe act of separating the essential qualities of an idea or object from the details of how it works or is composed. |
|
|
|
|
|
|
|
|
With abstraction, we focus on the what, not the how. For example, our understanding of automobiles is largely based on abstraction. Most of us know what the engine does (it propels the car), but fewer of us knowor want to knowprecisely how the engine works internally. Abstraction allows us to discuss, think about, and use automobiles without having to know everything about how they work. |
|
|
|
|
|
|
|
|
In the world of software design, it is now recognized that abstraction is an absolute necessity for managing immense, complex software projects. In introductory computer science courses, programs are usually small (perhaps 50 to 200 lines of code) and understandable in their entirety by one person. However, large commercial software products composed of hundreds of thousandseven millionsof lines of code cannot be designed, understood, or proven correct without using abstraction in various forms. To manage complexity, software developers regularly use two important abstraction techniques: control abstraction and data abstraction. |
|
|
|
|
|
|
|
|
In Chapter 8, we defined control abstraction as the separation of the logical properties of an action from its implementation. We engage in control abstraction whenever we write a function that reduces a complicated algorithm to an abstract action performed by a function call. By invoking a library function, as in the expression |
|
|
|
|
|