Reusing Your Code and Modularity
The code you write to solve problems is only useful if you, or others, can use it. This means you have to think quite carefully about how others (including yourself, who might have forgotten how things work) interface and otherwise interact with your solution. This starts with the interface to your solution, which should be simple and stable, but allow for flexibility where it exists. The next challenge is packaging the solution into a library that can be used elsewhere in applications (or other libraries). This is the main topic of this chapter.
In the first part of the chapter, we will discuss some of the considerations of building libraries in C++, particularly some of the challenges associated with building shared libraries. Designing interfaces is something we discussed in previous chapters and appears again here. This time the focus is on stability which is critical, especially for shared libraries, for making your code usable. We also look...