Back to [[conference:committee:2015-proposals]]\\ \\ **Title**: Dependency Injection in C++ (based on proposed Boost.DI library)\\ **Proposer**: [[2015:Krzysztof Jusiak]]\\ **Type**: Tutorial\\ **Duration**: 90 mins\\ **Description**: \\ Dependency injection is a common design pattern widely used in languages like Java(Google Guice) and C#(Ninject). Unfortunately C++ seems to be behind with this programming practice, probably due to the lack of C++ libraries which wouldn't cause performance degradation, be intrusive or easy to use/integrate. On the other hand C++ community seem not to be convinced that automatic dependency injection framework might be implemented without performance degradation or in a non intrusive way - due to lack of reflection support. In the talk the author will try to bust the myth about dependency injection in C++, explain what dependency injection actually is, what are the forms of dependency injection, why is it worth to consider using DI in order to have more loosely coupled code as well as better testability, how it differs from design patterns such as service locator, factory and finally how to automate dependency injection in C++ using C++14 standard (based on proposed Boost.DI library). Addressed problems will concern how to implement non intrusive version of constructor dependency injection (macro free), how to accomplish compile time creation guarantee (no run-time exceptions), how to manage dependencies life time (using scopes), how to limit allowed types (using compile time policies), how to improve application run-time performance when using DI (performing single allocation). Author will also try to recommend good practices when using DI such as composition root and SOLID principle. Testability issues will be presented with focus on unit-testing and integration-testing using C++ automatic mock injection based on DI (https://github.com/krzysztof-jusiak/mocks_injector). Integration with applications/libraries will be described based on Boost Meta State Machine library and Simple DirectMedia Layer Library (libSDL2). Level of the second part of the talk (how to automate dependency injection in C++) will be advanced and will require basic understanding of meta-programming techniques as well as C++14 features. Rest of the talk will require basic understanding of design patterns and C++. The library might be found on github (https://github.com/krzysztof-jusiak/di) with documentation (http://krzysztof-jusiak.github.io/di/boost/libs/di/doc/html). \\ \\ \\ \\