473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Oct 11 '06 #1
5 6580
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

Oct 11 '06 #2
On Wed, 11 Oct 2006 12:21:36 GMT, Michael Feathers
<mf*******@objectmentor.comwrote:
>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
Oct 11 '06 #3

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
Oct 13 '06 #4

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
Oct 13 '06 #5
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?

Oct 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nadav | last post by:
Hi, I am writing some kind of an encryptor for.NET assemblies, This require me: A. To encrypt the IL code ( done successfully ) B. To enable transparent means of decrypting the IL code on...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
8
by: stirrell | last post by:
Hello, One problem that I had been having is stopping email injections on contact forms. I did some research, read up on it and felt like I had created a working solution. I hadn't gotten any...
7
by: | last post by:
There are assorted "SQL Injection vulnerability assessment tools" out there. They scan your site and send your report. They also take your money. We don't have the money so I was wondering if I...
2
by: Anonieko | last post by:
Pigsaw said... "You don't want to hard code dependencies into your classes, because then you can't test them without relying on the dependent classes. So you "inject" those dependencies simply...
3
by: nguyen.panther | last post by:
Hi, Are there any solution for me to perform dependency injection in Activator.CreateInstance(myType) ??? Please help me.
3
by: Danno | last post by:
Just that simple question....out of curiosity.
2
by: Sudhakar | last post by:
A) validating username in php as part of a registration form a user fills there desired username and this is stored in a mysql. there are certain conditions for the username. a) the username...
3
by: -Lost | last post by:
Runtime dependency loading, worth the trouble? I've been researching methods of "dynamically" loading and unloading dependencies at runtime (trying my best to think of a nice solution of loading...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.