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

luiz americo pereira camara luizmed at oi.com.br
Mon Jan 5 21:07:52 CET 2015


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

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


More information about the Lazarus mailing list