does anyone know of any Spring.Container examples (preferably non trivial) that show how to build an app with a container just referenced from the Composition Root?

Comments

  1. The principle of having a composition root has nothing to do with a particular DI container. Its what you eventually get when following the principle if DI: ask for dependencies - don't create or look for them yourself (aka service locator).

    You did not mention it but I guess you mean a VCL application - now the design of the VCL is not particularly built with DI in mind and thus it can be a bit tricky to hook up the application mainform to the container to get it injected everything. However there are several examples how to achieve that (mainly by using DelegateTo and doing the Application.CreateForm there).

    ReplyDelete
  2. Stefan Glienke thanks, yes I was thinking of a VCL forms app. I know it is a general DI approach, but it would be useful to have examples, even non forms apps. It would be great if Nick Hodges could rework his examples from the book to reflect this - well it would help me get my head around it anyway :-)

    ReplyDelete
  3. From my limited experiece, DelegateTo and RegisterType.AsFactory are the key methods to achieve that.

    ReplyDelete

Post a Comment