MFC Programmer's SourceBook : Thinking in C++
Bruce Eckel's Thinking in C++, 2nd Ed Contents | Prev | Next

4: Data abstraction

C++ is a productivity enhancement tool. Why else would you make the effort (and it is an effort, regardless of how easy we attempt to make the transition)

to switch from some language that you already know and are productive in (C, in this case) to a new language where you’re going to be less productive for a while, until you get the hang of it? It’s because you’ve become convinced that you’re going to get big gains by using this new tool.

Productivity, in computer programming terms, means that fewer people can make much more complex and impressive programs in less time. There are certainly other issues when it comes to choosing a language, like efficiency (does the nature of the language cause code bloat?), safety (does the language help you ensure that your program will always do what you plan, and handle errors gracefully?), and maintenance (does the language help you create code that is easy to understand, modify and extend?). These are certainly important factors that will be examined in this book.

But raw productivity means a program that might take three of you a week takes one of you a day or two. This touches several levels of economics. You’re happy because you get the rush of power that comes from building something, your client (or boss) is happy because products are produced faster and with fewer people, and the customers are happy because they get products more cheaply. The only way to get massive increases in productivity is to leverage off other people’s code, that is, to use libraries.

A library is simply a bunch of code that someone else has written, packaged together somehow. Often, the most minimal package is a file with an extension like .LIB and one or more header files to declare what’s in the library to your compiler. The linker knows how to search through the LIB file and extract the appropriate compiled code. But that’s only one way to deliver a library. On platforms that span many architectures, like Unix, often the only sensible way to deliver a library is with source code, so it can be recompiled on the new target. And on Microsoft Windows, the dynamic-link library (DLL) is a much more sensible approach – for one thing, you can often update your program by sending out a new DLL, which your library vendor may have sent you.

So libraries are probably the most important way to improve productivity, and one of the primary design goals of C++ is to make library use easier. This implies that there’s something hard about using libraries in C. Understanding this factor will give you a first insight into the design of C++, and thus insight into how to use it.

Contents | Prev | Next


Go to CodeGuru.com
Contact: webmaster@codeguru.com
© Copyright 1997-1999 CodeGuru