Is it in the C++ culture to use Dependency Injection/Inversion ofControl?

Discussion in 'C++' started by Danno, Apr 9, 2008.

  1. Danno

    Danno Guest

    Just that simple question....out of curiosity.
    Danno, Apr 9, 2008
    #1
    1. Advertising

  2. Danno

    Ian Collins Guest

    Re: Is it in the C++ culture to use Dependency Injection/Inversionof Control?

    Danno wrote:
    > Just that simple question....out of curiosity.


    Which is?

    --
    Ian Collins.
    Ian Collins, Apr 9, 2008
    #2
    1. Advertising

  3. Re: Is it in the C++ culture to use Dependency Injection/Inversionof Control?

    Danno wrote:
    > Just that simple question....out of curiosity.


    Two things:

    1) It's common netiquette to write the contents of the post in the
    body of the post, not in its subject. The subject line is just a quick
    intro to the post itself, it's not the post. The post should be
    completely understandable even if the subject line was completely removed.

    2) You are clearly trying to be a smart-ass by using complicated
    terminology that only few people are acquainted with, clearly on
    purpose. If you don't want people to think you are a smart-ass, explain
    your terminology before using it.
    Juha Nieminen, Apr 9, 2008
    #3
  4. On Apr 9, 6:07 am, Danno <> wrote:
    [Subject] : Is it in the C++ culture to use Dependency Injection/
    Inversion of Control?
    > Just that simple question....out of curiosity.


    If you are hinting towards AOP, you could refer this: http://www.aspectc.org/
    Abhishek Padmanabh, Apr 9, 2008
    #4
  5. Danno

    Danno Guest

    On Apr 8, 7:13 pm, Ian Collins <> wrote:
    > Danno wrote:
    > > Just that simple question....out of curiosity.

    >
    > Which is?
    >
    > --
    > Ian Collins.


    Well, the seminal articles are by Martin Fowler.
    http://martinfowler.com/bliki/InversionOfControl.html
    http://martinfowler.com/articles/injection.html

    It is a way of designing classes, therefore objects, to be injected
    with what they need instead of tight coupling relationships to other
    classes & objects by instantiation or non-abstract assignements. This
    is also usually done with abstractions (interface oriented design).
    In Java and Ruby, objects are injected with the objects they require
    by text, xml, or dsl file.
    Danno, Apr 9, 2008
    #5
  6. Danno

    Danno Guest

    On Apr 8, 11:16 pm, Juha Nieminen <> wrote:
    > Danno wrote:
    > > Just that simple question....out of curiosity.

    >
    > Two things:
    >
    > 1) It's common netiquette to write the contents of the post in the
    > body of the post, not in its subject. The subject line is just a quick
    > intro to the post itself, it's not the post. The post should be
    > completely understandable even if the subject line was completely removed.
    >
    > 2) You are clearly trying to be a smart-ass by using complicated
    > terminology that only few people are acquainted with, clearly on
    > purpose. If you don't want people to think you are a smart-ass, explain
    > your terminology before using it.


    Calm down, my god, this group is too egotistical, pious and angry.

    I am trying to educate myself with different languages and I asked one
    simple question here on c.l.c++ a couple of weeks ago about pointers
    and I get jumped on by one of your members. Now I ask another question
    about DI/IoC and you think it's an affront to your intelligence? Are
    you guys that sensitive and insecure about yourselves to go bashing
    posters?

    Don't worry, this will be last participation in this group for me, you
    guys can proceed with your "don't hit your ass on the way out" party.
    There are plenty open academic discussion groups out there.
    Danno, Apr 9, 2008
    #6
  7. Danno

    Danno Guest

    On Apr 8, 11:35 pm, Abhishek Padmanabh <>
    wrote:
    > On Apr 9, 6:07 am, Danno <> wrote:
    > [Subject] : Is it in the C++ culture to use Dependency Injection/
    > Inversion of Control?
    >
    > > Just that simple question....out of curiosity.

    >
    > If you are hinting towards AOP, you could refer this:http://www.aspectc.org/


    No, but that is some great info, and I appreciate the link.

    I posted the info on Dependency Injection and Inversion of Control on
    the response to Ian.
    Danno, Apr 9, 2008
    #7
  8. Danno

    Ian Collins Guest

    Re: Is it in the C++ culture to use Dependency Injection/Inversionof Control?

    Danno wrote:
    > On Apr 8, 7:13 pm, Ian Collins <> wrote:
    >> Danno wrote:
    >>> Just that simple question....out of curiosity.

    >> Which is?
    >>

    >
    > Well, the seminal articles are by Martin Fowler.
    > http://martinfowler.com/bliki/InversionOfControl.html
    > http://martinfowler.com/articles/injection.html
    >
    > It is a way of designing classes, therefore objects, to be injected
    > with what they need instead of tight coupling relationships to other
    > classes & objects by instantiation or non-abstract assignements. This
    > is also usually done with abstractions (interface oriented design).
    > In Java and Ruby, objects are injected with the objects they require
    > by text, xml, or dsl file.
    >

    Ah, I wasn't sure what the question was. It's been a while since I read
    those papers (it's well worth spending time on Martin's site, there are
    some real gems there), but I think I remember the gist.

    C++ classes don't support dynamic binding, but it can be approximated
    with callback functions and/or functors. SO yes, a C++ class can be
    instantiated and then have specific behaviour "injected". I guess the
    good old C callback functions is the most basic form of IoC.

    --
    Ian Collins.
    Ian Collins, Apr 9, 2008
    #8
  9. Danno

    arnuld Guest

    Re: Is it in the C++ culture to use Dependency Injection/Inversion of Control?

    > On Tue, 08 Apr 2008 23:04:02 -0700, Danno wrote:


    > Calm down, my god, this group is too egotistical, pious and angry.


    really ?

    when I saw your post for 1st time, you seem like you were either trying to
    be over-smart or you are stupid. I am not saying you are idiot/smart-ass.
    I am saying the way you communicate your question to comp.lang.c++,
    then it shew that way.

    The way youo asked your question with *zero* words in your post reminds of
    the programmers from 1late 90s "IT Revolution" era. Many persons called
    themselves HTML Programmers at that time. Now I added your name onto that
    list.



    > I am trying to educate myself with different languages and I asked one
    > simple question here on c.l.c++ a couple of weeks ago about pointers and
    > I get jumped on by one of your members. Now I ask another question about
    > DI/IoC and you think it's an affront to your intelligence? Are you guys
    > that sensitive and insecure about yourselves to go bashing posters?


    No one is bashing you here. *They* are trying to educate you. Juha
    Nieminen did the same and there were no harsh words in his reply.


    > Don't worry, this will be last participation in this group for me, you
    > guys can proceed with your "don't hit your ass on the way out" party.
    > There are plenty open academic discussion groups out there.


    yes, they are there. comp.lang.c++ is a kind of group where
    regular-posters are much more matured, intelligent and patient than what
    you will experience on other groups.

    try yourself but it will take a lot of personal-time of yours before you
    find that out.





    -- http://lispmachine.wordpress.com/

    Please remove capital 'V's when you reply to me via e-mail.
    arnuld, Apr 9, 2008
    #9
  10. Re: Is it in the C++ culture to use Dependency Injection/Inversion of Control?

    Ian Collins <> wrote in news:663cgoF2hu9ejU9
    @mid.individual.net:

    > Danno wrote:
    >> On Apr 8, 7:13 pm, Ian Collins <> wrote:
    >>> Danno wrote:
    >>>> Just that simple question....out of curiosity.
    >>> Which is?
    >>>

    >>
    >> Well, the seminal articles are by Martin Fowler.
    >> http://martinfowler.com/bliki/InversionOfControl.html
    >> http://martinfowler.com/articles/injection.html
    >>
    >> It is a way of designing classes, therefore objects, to be injected
    >> with what they need instead of tight coupling relationships to other
    >> classes & objects by instantiation or non-abstract assignements. >
    >> C++ classes don't support dynamic binding,


    Isn't plain old LSP an instance of DI? The client code only knows the
    interface, not the implementing classes. If you link dynamically, you
    can plug and play different modules.

    The kind of DI used in dynamic languages like Ruby and Python (which
    I've used) can lead to debugging and maintenance nightmares when your
    behavior is specified in code as well as config files.
    Lloyd Bonafide, Apr 9, 2008
    #10
  11. Danno

    Danno Guest

    On Apr 9, 6:12 am, Lloyd Bonafide <> wrote:
    > Ian Collins <> wrote in news:663cgoF2hu9ejU9
    > @mid.individual.net:
    >
    > > Danno wrote:
    > >> On Apr 8, 7:13 pm, Ian Collins <> wrote:
    > >>> Danno wrote:
    > >>>> Just that simple question....out of curiosity.
    > >>> Which is?

    >
    > >> Well, the seminal articles are by Martin Fowler.
    > >>http://martinfowler.com/bliki/InversionOfControl.html
    > >>http://martinfowler.com/articles/injection.html

    >
    > >> It is a way of designing classes, therefore objects, to be injected
    > >> with what they need instead of tight coupling relationships to other
    > >> classes & objects by instantiation or non-abstract assignements. >
    > >> C++ classes don't support dynamic binding,

    >
    > Isn't plain old LSP an instance of DI? The client code only knows the
    > interface, not the implementing classes. If you link dynamically, you
    > can plug and play different modules.
    >
    > The kind of DI used in dynamic languages like Ruby and Python (which
    > I've used) can lead to debugging and maintenance nightmares when your
    > behavior is specified in code as well as config files.


    That is definitely one of the major complaints about DI. Some
    developers get blamed for overdoing it by making their code as
    anorexic as possible.

    I pulled up the DI page on wikipedia and it offers frameworks in C++:

    http://code.google.com/p/autumnframework/
    http://code.google.com/p/pococapsule/
    http://qtioccontainer.sourceforge.net/
    Danno, Apr 9, 2008
    #11
  12. Danno

    Danno Guest

    On Apr 9, 2:19 am, Ian Collins <> wrote:
    > Danno wrote:
    > > On Apr 8, 7:13 pm, Ian Collins <> wrote:
    > >> Danno wrote:
    > >>> Just that simple question....out of curiosity.
    > >> Which is?

    >
    > > Well, the seminal articles are by Martin Fowler.
    > >http://martinfowler.com/bliki/InversionOfControl.html
    > >http://martinfowler.com/articles/injection.html

    >
    > > It is a way of designing classes, therefore objects, to be injected
    > > with what they need instead of tight coupling relationships to other
    > > classes & objects by instantiation or non-abstract assignements. This
    > > is also usually done with abstractions (interface oriented design).
    > > In Java and Ruby, objects are injected with the objects they require
    > > by text, xml, or dsl file.

    >
    > Ah, I wasn't sure what the question was. It's been a while since I read
    > those papers (it's well worth spending time on Martin's site, there are
    > some real gems there), but I think I remember the gist.
    >
    > C++ classes don't support dynamic binding, but it can be approximated
    > with callback functions and/or functors.


    Now I know what callback functions are, but they may have different
    meaning in a C++ context (or may not). I had no clue what functors
    were until you posted. I googled it and found out. It looks like that
    is probably the best way to do injections.

    > SO yes, a C++ class can be
    > instantiated and then have specific behaviour "injected". I guess the
    > good old C callback functions is the most basic form of IoC.
    >
    Danno, Apr 9, 2008
    #12
  13. Danno

    Ke Jin Guest

    On Apr 8, 6:07 pm, Danno <> wrote:
    > Just that simple question....out of curiosity.


    In C++ applications, it is pretty common that object dependencies are
    configured (wired up) by passing depender references as input
    parameters of plain old C++ constructs, static methods (e.g.
    factories), setters, as well as other virtual/non-virtual member
    functions of dependee objects. So, from this sense, one could claim
    that dependency injection (DI) has been a C++ calture for decades.

    To change the question more specific to "DI framework support in C++",
    there are several of them already. For instance, the PocoCapsule
    (<http://code.google.com/p/pococapsule) supports framework agnostic
    plain-old C++ objects (POCO).

    Hope this helps,
    Ke
    Ke Jin, Apr 10, 2008
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Matthews

    Dependency Inversion Principle Dilemma

    Thomas Matthews, Dec 18, 2003, in forum: C++
    Replies:
    12
    Views:
    640
    Mike Smith
    Dec 23, 2003
  2. Replies:
    2
    Views:
    361
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
    Jun 8, 2007
  3. Replies:
    2
    Views:
    3,060
    SadRed
    Jun 9, 2007
  4. Replies:
    0
    Views:
    292
  5. Replies:
    8
    Views:
    215
    Robert Klemme
    Jun 14, 2007
Loading...

Share This Page