Designing stable interfaces
Public interfaces need to be stable. Intermediate users (which may include yourself) will build applications and other libraries that consume your interface and use it. Asking those users to recompile their software every time you ship a new shared library is unreasonable (and in many cases impossible). Static libraries don’t have the same problem since the code is baked into those applications, but stability is important there too. Having an interface that doesn’t change in ways that break existing functionality is important. There are many things to consider here, such as how to add new functionality, how to change behavior, and how to deprecate and eventually remove old functionality.
Before we get to some of the ways to safely change interfaces, we can give some general tips for how to build good interfaces that are flexible from the start, and thus are less problematic to change later. Here are a few general tips:
- Layer...