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

Marcos Douglas md at delfire.net
Tue Jan 6 01:44:15 CET 2015


On Mon, Jan 5, 2015 at 6:07 PM, luiz americo pereira camara
<luizmed at oi.com.br> wrote:
> Starting a new thread.
>
>
> 2015-01-05 15:16 GMT-03:00 silvioprog <silvioprog at gmail.com>:
>>
>> On Mon, Jan 5, 2015 at 12:54 PM, Marco van de Voort <marcov at stack.nl>
>> wrote:
>>>
>>>
>>> As a first step in the 3.0.0 release process the stable branch was
>>> branched
>>> off to branches/fixes_3_0 and the version number was updated to 3.0.1
>>>
>>> The version in trunk was raised to 3.1.1
>>>
>>> Scripts might need modification accordingly.
>>
>>
>> Good news!
>>
>> Chances of custom attributes[1] (or something like this) in release 3.0? I
>> have plans to use IoC[2] and DI using this feature.
>>
>
> 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.
>
> With it is possible to implement Service Locator and Property Injection
> patterns. Constructor Injection is not possible due to lacking of Extended
> RTTI support in fpc.
>
> While the C# crowd  praises the Constructor Injection pattern (
> http://www.devtrends.co.uk/blog/how-not-to-do-dependency-injection-the-static-or-singleton-container
> ), i had hard times figuring how it would work in real world / Lazarus
> projects. Also, polluting the constructor  signature is not something that i
> like. And finally with Constructor Injection is not possible to use with
> TComponent / TForm
>
> 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?

Regards,
Marcos Douglas




More information about the Lazarus mailing list