Boost logo

Boost :

From: Krzysztof Jusiak (krzysztof_at_[hidden])
Date: 2021-02-19 22:20:34


On Fri, Feb 19, 2021 at 1:27 PM Andrzej Krzemienski via Boost <
boost_at_[hidden]> wrote:

> czw., 18 lut 2021 o 20:58 Krzysztof Jusiak via Boost <
> boost_at_[hidden]>
> napisał(a):
>
> > Hi,
> >
> > I just wanted to share, potentially useful for the Boost and C++
> community,
> > libraries and ask if anyone would be willing to become a Review Manager
> for
> > any of them?
> >
> > [boost-ext] (https://github.com/boost-ext) is a collection of C++
> > libraries
> > with aspirations to be included in Boost. Libraries can be characterized
> > by:
> > * Modern C++ (>= C++14)
> > * Header/Single Module only
> > * No dependencies
> >
> > ATM, [boost::ext] consists of four core libraries:
> >
> > * DI - Dependency Injection Library
> > overview:
> > standard: C++14
> > single header with no dependencies (neither STL nor Boost is
> > required)
> > release: 1.2.0 (first release - 2014)
> > key features:
> > - supports macro-free constructor injection
> > - supports templates injection
> > - quick compilation-times
> > - highly optimized code generation
> > try it online: https://godbolt.org/z/5qTKhf
> > source code: https://github.com/boost-ext/di
> > documentation: https://boost-ext.github.io/di/
>
>
> Regarding the DI library, I read the introduction and the tutorial part,
> and it does not help me understand what problem this library solves or why
> I should use it. Is there some other way to explain what this library is
> for?
>

I was hoping that the explantation from https://boost-ext.github.io/di/boost
is good enough but I understand it might be confusing.
DI is a very simple concept, actually. The main point is to make the code
less coupled by injecting dependencies which is usually done by passing
them through constructors.
I'd hope that the following talk -
https://www.youtube.com/watch?v=yVogS4NbL6U is a good explanation of DI as
well. I'm happy to follow-up in any form, though.

> Or maybe I need to switch my mindset to Java-like OO patterns a la GoF in
> order to appreciate this?
>

Right, Dependency Injection is related to OO patterns and especially the
SOLI-D (Dependency Inversion) principle.

> Is there a lot of theory that I have to learn prior to be able to
> understand what it is for?
>

Not sure, OO, SOLID should be more than enough, IMHO.

>
> The docs give this example:
>
> auto injector = di::make_injector();
> injector.create<app>();
>
> Does this create a temporary object of type `app` that vanishes
> momentarily? Or is there some magical object lifetime management going on
> behind the scenes?
>

That will depend on the scope. By default, it's a singleton scope so the
app will have the same lifetime as the program.

Some useful information can be found:
- https://boost-ext.github.io/di/user_guide.html#scopes
- https://boost-ext.github.io/di/tutorial.html

> Also, it looks like it will only work if the leaves of this dependency tree
> are default-constructible and if I am happy with calling default
> constructors. But usually I am not: I need to pass arguments to my objects,
> even if they are leaves in the dependency tree.
>
> DI deduces constructor parameters automatically so it works with
non-default-constructible types as well.
DI is capable of creating the whole dependency tree.

Potential examples which can maybe help
-
https://github.com/boost-ext/di/blob/cpp14/example/tutorial/basic_create_objects_tree.cpp
- https://github.com/boost-ext/di/blob/cpp14/example/motivation.cpp
- https://github.com/boost-ext/di/tree/cpp14/example/polymorphism

> I would appreciate help in understanding the motivation.
>

I hope that the examples and explanation helps a bit, but if not I'm also
more than happy/available to have a follow-up (via zoom or similar) if that
helps (feedback could be used to improve the documentation)?

> Regards,
> &rzej;
>
> >
> >
> > * SML - State Machine Library
> > overview:
> > standard: C++14
> > single header with no dependencies (neither STL nor Boost is
> > required)
> > release: 1.1.4 (first release - 2016)
> > key features:
> > - much faster compilation-times than Boost.MSM (up to 60x faster)
> > - highly optimized and customizable code generation
> > - suitable for embedded systems
> > try it online: https://godbolt.org/z/y99L50
> > source code: https://github.com/boost-ext/sml
> > documentation: https://boost-ext.github.io/sml/
> >
> > * UT - Unit Testing Framework
> > overview:
> > standard: C++20
> > single header with no dependencies (STL required)
> > release: 1.1.8 (first release - 2019)
> > key features:
> > - macro-free
> > - minimal boilerplate
> > - fast compilation-times and execution
> > try it online: https://godbolt.org/z/Jqb5Ye
> > source code: https://github.com/boost-ext/ut
> > documentation: https://boost-ext.github.io/ut
> >
> > * TE - Run-time polymorphism (type erasure) library
> > overview:
> > standard: C++17
> > single header with no dependencies (STL required)
> > release: -
> > key features:
> > - simple interface
> > - highly optimized code generation
> > try it online: https://godbolt.org/z/xY9MEq
> > source code: https://github.com/boost-ext/te
> > documentation: https://github.com/boost-ext/te
> >
> > All libraries (except TE) were successfully deployed in the production
> > systems.
> > Some, such as DI and SML are used by well known/big IT companies as well.
> >
> > If anyone is interested in becoming a Review Manager for any of
> > the libraries, I'd really appreciate it and I'll more than happy to
> address
> > any issues/requests before the review as well as help with any
> > process-related tasks.
> >
> > Thank you very much,
> > -Kris
> >
> > _______________________________________________
> > Unsubscribe & other changes:
> > http://lists.boost.org/mailman/listinfo.cgi/boost
> >
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk