Breadboard ( abbreviated as BB ) is a small library that brings dependency injection capability to a C++ program with minimal modifications to its source code.
Classes can be easily injected, replaced or extended from outside without breaking the code currently using them. This provides an opportunity to developers to
construct extensible and testable applications with less efforts.
The major benefit a system obtains after using BB is that any parts of it can be replaced or extended from outside with minimum or zero side effects. The whole system
follows the 'open closed principle' (OCP)
except a small piece of code that decides which concrete class will be injected to the system. This code can be used as a configuration
file to tailor the application at link time pretty much the same way as a 'config.h' does at compile time.
A unit test framework can use BB to create controlled testing environments by injecting mock objects to the system to replace or extend the real dependencies of code being tested.
An interesting feature of a system using BB is that all concrete classes are invisible from each other. They can only be accessed through the public interface it inherited from. The only place
they can be refered is within the injection code. Because of this, any classes that are not injected are marked by the linker as dead-code and are excluded from the final executable. This feature
can be used to customize an application at link time but have all its source files compiled and validated by the compiler.
How does it work