Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Dependency Injection in C++

Reply
Thread Tools

Dependency Injection in C++

 
 
Michael Feathers
Guest
Posts: n/a
 
      10-11-2006

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
 
Reply With Quote
 
 
 
 
KiLVaiDeN
Guest
Posts: n/a
 
      10-11-2006
> 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

 
Reply With Quote
 
 
 
 
Roland Pibinger
Guest
Posts: n/a
 
      10-11-2006
On Wed, 11 Oct 2006 12:21:36 GMT, Michael Feathers
<(E-Mail Removed)> 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
 
Reply With Quote
 
prod@pocomatic.com
Guest
Posts: n/a
 
      10-13-2006

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


 
Reply With Quote
 
prod@pocomatic.com
Guest
Posts: n/a
 
      10-13-2006

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


 
Reply With Quote
 
F.J.K.
Guest
Posts: n/a
 
      10-13-2006
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dependency Injection vs. Global/Static data thomas C++ 6 09-03-2010 01:32 AM
Immutable cyclic graph with dependency injection Philipp Java 8 06-29-2009 07:53 PM
Is it in the C++ culture to use Dependency Injection/Inversion ofControl? Danno C++ 12 04-10-2008 08:08 PM
What is Dependency Injection? Anonieko ASP .Net 2 10-14-2007 12:03 PM
How to build a dependency injection framework by myself? =?iso-8859-1?B?bW9vcJk=?= Java 4 08-24-2006 06:57 PM



Advertisments