Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Dependency Injection in C++ (http://www.velocityreviews.com/forums/t457562-dependency-injection-in-c.html)

Michael Feathers 10-11-2006 12:21 PM

Dependency Injection in C++
 

Why aren't there many libraries for Dependency Injection in C++. It's
been a very useful pattern in the Java community, but I run into many
teams that could use it in C++, but it never occurs to them to write a
framework to do it.

Blogged about here:
michaelfeathers.typepad.com/michael_feathers_blog/2006/10/dependency_inje.html


Michael Feathers
www.objectmentor.com

KiLVaiDeN 10-11-2006 12:31 PM

Re: Dependency Injection in C++
 
> Michael Feathers wrote:
>
> Why aren't there many libraries for Dependency Injection in C++. It's
> been a very useful pattern in the Java community, but I run into many
> teams that could use it in C++, but it never occurs to them to write a
> framework to do it.
>
> Blogged about here:
> michaelfeathers.typepad.com/michael_feathers_blog/2006/10/dependency_inje.html
>
>
> Michael Feathers
> www.objectmentor.com


What about http://sourceforge.net/projects/qtioccontainer ?

It looks like it's more popular in Java, because it's pretty usefull in
multi-tiered applications.
I'll take a look to your blog sooner or later ;)

Cheers,
K


Roland Pibinger 10-11-2006 01:35 PM

Re: Dependency Injection in C++
 
On Wed, 11 Oct 2006 12:21:36 GMT, Michael Feathers
<mfeathers@objectmentor.com> wrote:
>Why aren't there many libraries for Dependency Injection in C++. It's
>been a very useful pattern in the Java community, but I run into many
>teams that could use it in C++, but it never occurs to them to write a
>framework to do it.


It can be done as explained here:
http://www.objectmentor.com/omReports/articles/dip.pdf .
It cannot be done as in Java because fortunately C++ has no
reflection. BTW, IOC a la Spring is totally overhyped in Java land but
the counter movement will come soon (IOC trades hard compile-time
dependencies for weak run-time dependencies).

>Blogged about here:
>michaelfeathers.typepad.com/michael_feathers_blog/2006/10/dependency_inje.html


Testability depends on design for testability. DI doesn't
automatically enhance testabilty.

Best regards,
Roland Pibinger

prod@pocomatic.com 10-13-2006 02:27 AM

Re: Dependency Injection in C++
 

KiLVaiDeN wrote:
> > Michael Feathers wrote:
> >
> > Why aren't there many libraries for Dependency Injection in C++. It's
> > been a very useful pattern in the Java community, but I run into many
> > teams that could use it in C++, but it never occurs to them to write a
> > framework to do it.
> >
> > Blogged about here:
> > michaelfeathers.typepad.com/michael_feathers_blog/2006/10/dependency_inje.html
> >
> >
> > Michael Feathers
> > www.objectmentor.com

>
> What about http://sourceforge.net/projects/qtioccontainer ?
>


The QTIoccontainer is hardly qualified as an IoC or DI container, as it
is intrusive and does not support POCO (Plain Old C++ Object). Besides,
it only supports setter injection, the weakest form of the DI pattern.

Regards,
Ke

> It looks like it's more popular in Java, because it's pretty usefull in
> multi-tiered applications.
> I'll take a look to your blog sooner or later ;)
>
> Cheers,
> K



prod@pocomatic.com 10-13-2006 02:41 AM

Re: Dependency Injection in C++
 

Roland Pibinger wrote:
> >Blogged about here:
> >michaelfeathers.typepad.com/michael_feathers_blog/2006/10/dependency_inje.html

>
> Testability depends on design for testability. DI doesn't
> automatically enhance testabilty.
>


I partially agree. In fact, saying "IoC enhaces testability" is only
relative to the intrusive EJB pre-3.0. As IoC frameworks support
non-intrusive POJO (Plain Old Java Object), they allow business logic
beans to be tested outside their frameworks easily. In C++ world, most
applications don't use intrusive frameworks similar to the EJB pre-3.0,
therefore, the testability with or without IoC should be the same.

Regards,
Ke

> Best regards,
> Roland Pibinger



F.J.K. 10-13-2006 08:23 AM

Re: Dependency Injection in C++
 
Michael Feathers wrote:
> Why aren't there many libraries for Dependency Injection in C++. It's
> been a very useful pattern in the Java community, but I run into many
> teams that could use it in C++, but it never occurs to them to write a
> framework to do it.


I read Roland Piebingers link,
http://www.objectmentor.com/omReports/articles/dip.pdf and think it's
an interesting, very flexible and "enterprisey" pattern. However, I
fail to grasp the difference from the simple rule: "Use abstract
interface classes everywhere." (Doesn't the QT framework favor this?)

I hope I'm not terribly dense but if I understand this correctly this
automatically means using "virtual" all over the place. If you are
interested in FLOPS this is a killer. Again, I might be completely
wrong, but I think on the lower software layers, this technique is
unusable performancewise. At least I personally always try to define
functional interfaces for templates and get rid of as many virtuals as
possible when writing scientific code.

So maybe JAVA has better use for it, as it is used more as an
integrative, "scripty" language than C++ ? Or maybe the C++ community
is used more to following design patterns, without a framework
enforcing it?



All times are GMT. The time now is 01:57 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.