WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: Re: Dependency injection

Re: Re: Dependency injection

by Mario Pareja :: Rate this Message:

| View in Thread

It looks like you need to take advantage of convention based registration
here.

Mario

On Thu, Feb 17, 2011 at 11:22 AM, Serhat Özgel <serhatozgel@...>wrote:

>
>
> It is less or more like this:
>
> Controllers are mvc controllers, which get data from client, converts it
> into dtos and passes to services. Repositories generally contain unique
> methods to that domain. A common repository is used for common stuff like
> simple selects, crud, etc. Business logic goes to services and services
> already contain lots of code so  it would not be a good idea to reduce their
> numbers (we must do the opposite).
>
>
> _container.Register(Component.For<IKController>().ImplementedBy<KController>().LifeStyle.Transient);
>
> _container.Register(Component.For<IYController>().ImplementedBy<YController>().LifeStyle.Transient);
>
> _container.Register(Component.For<IZController>().ImplementedBy<ZController>().LifeStyle.Transient);
> (goes on for 100 lines)
> ...
>
> _container.Register(Component.For<IKService>().ImplementedBy<KService>().LifeStyle.Transient);
>
> _container.Register(Component.For<ILService>().ImplementedBy<LService>().LifeStyle.Transient);
>
> _container.Register(Component.For<IMService>().ImplementedBy<MService>().LifeStyle.Transient);
> (goes on for 300 lines)
> ...
>
> _container.Register(Component.For<IDomainXRepository>().ImplementedBy<XDomainRepository>().LifeStyle.Transient);
>
> _container.Register(Component.For<IDomainYRepository>().ImplementedBy<YDomainRepository>().LifeStyle.Transient);
>
> _container.Register(Component.For<IDomainZRepository>().ImplementedBy<ZDomainRepository>().LifeStyle.Transient);
> (goes on for 200 lines)
> ...
>
> _container.Register(Component.For<IEncryptor>().ImplementedBy<BcryptEncryptor>());
>
> ._container.Register(Component.For<IJsonSerializer>().ImplementedBy<Serialization.Impl.JsonSerializer>());
>
> _container.Register(Component.For<IResourceReader>().ImplementedBy<ResourceReader>());
>
> _container.Register(Component.For<IXmlSerializer>().ImplementedBy<XmlSerializer>());
>
> _container.Register(Component.For<IUnitOfWorkFactory>().ImplementedBy<UnitOfWorkFactory>().LifeStyle.Transient);
> (goes on for 50 lines for utility stuff)
> ...
> [registrations for other stuff like imports, web services, etc.]
> (goes on for 50 lines)
> ...
>
> On Thu, Feb 17, 2011 at 5:52 PM, Steven Smith <ssmith.lists@...>wrote:
>
>>
>>
>> Maybe you are doing something wrong, maybe not.  I don't know that we on
>> the list have enough information to guide you one way or the other.  Can you
>> share a particular example that concerns you?
>>
>>
>> On Thu, Feb 17, 2011 at 10:47 AM, Serhat Özgel <serhatozgel@...>wrote:
>>
>>>
>>>
>>> We are using Castle Windsor. A fraction of this time may be taken by
>>> initializing nhibernate session or configuration facilities so I may have
>>> been wrong taking initialization time into consideration. My main issue is,
>>> we have too much dependencies that I am starting to think we are doing
>>> something wrong.
>>>
>>> On Thu, Feb 17, 2011 at 5:44 PM, Steven Smith <ssmith.lists@...>wrote:
>>>
>>>>
>>>>
>>>> What IOC container are you using that takes 10 seconds to wire up 1000
>>>> types on startup?
>>>>
>>>> Steve
>>>>
>>>>
>>>>
>>>> On Wed, Feb 16, 2011 at 5:36 PM, Serhat Özgel <serhatozgel@...>wrote:
>>>>
>>>>>
>>>>>
>>>>> In my case, we have a web app that has lots of modules. A business
>>>>> layer class has 5-6 dependencies on the average. We try to follow solid
>>>>> strictly, not perfect but almost there. The problem is, we have hundreds of
>>>>> classes that we register into our ioc container and it is growing. The
>>>>> registrations alone take nearly 10 seconds on app init. How would you deal
>>>>> with such a situation? Is it ok to have  hundreds or thousands of
>>>>> registrations in an app?
>>>>>
>>>>>
>>>>> On Wed, Feb 16, 2011 at 11:15 PM, Dotan N. <dipidi@...> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> I'm saying, once you unit test / integration test properly, you'll
>>>>>> discover the parts that are too sticky. It'll force you into more modular
>>>>>> design, and then you'll see how the modules grow apart.
>>>>>> These modules will depend upon each other in various ways, and it'll
>>>>>> be the DI's job to inject the dependencies.
>>>>>>
>>>>>>
>>>>>> On Wed, Feb 16, 2011 at 11:12 PM, kogerbnz <kogerbnz@...>wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> > unit/integration testing will show you the sweet spot
>>>>>>> >
>>>>>>> So are you saying that I should really only be using DI as seams for
>>>>>>> tests?
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Steve Smith
>>>> http://SteveSmithBlog.com/
>>>> http://twitter.com/ardalis
>>>>
>>>>
>>>
>>
>>
>> --
>> Steve Smith
>> http://SteveSmithBlog.com/
>> http://twitter.com/ardalis
>>
>>
>  
>

 « Return to Thread: Re: Dependency injection