[Lazarus] Inversion of control (IoC) and Dependency injection (DI)

luiz americo pereira camara luizmed at oi.com.br
Tue Jan 6 03:16:23 CET 2015


2015-01-05 21:44 GMT-03:00 Marcos Douglas <md at delfire.net>:

> On Mon, Jan 5, 2015 at 6:07 PM, luiz americo pereira camara
> >
> > I created a IoC Container that can be found at
> >
> https://code.google.com/p/luipack/source/browse/trunk/luicomponents/luiioccontainer.pas
> > . It has no dependencies.
>
> >
> > So in the end, i use the service locator and have plans to use Property
> > Injection pattern
> >
> > BTW: Custom Attributes support would help to have a nicer Property
> Injection
> > implementation
>
> Interesting.
> Could you give us some example how this class works?
>
>
There's a demo in demos/ioccontainer

In a working project i use a IPresentationManager
https://code.google.com/p/luipack/source/browse/trunk/luicontrols/presentationmanager.pas#36

When a class needs to use it, resolves from a TIoCContainer (Service
Locator pattern). The global variable and concrete class are not exposed.
In the other hand depends of the IoCContainer. I have plans to switch to a
Property Injection pattern that helps to decouple a bit more.

Luiz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150105/e1947d89/attachment-0003.html>


More information about the Lazarus mailing list