locked
Question regarding dependency injection in repository pattern RRS feed

  • Question

  • User-1002157272 posted

    I just wanted to get some clarification before I proceed with my design plan...

    I have a rather large project with the need for multiple repositories. Due to the size of the application and the architecture (nTier), I'm using constructor dependancy injection into the business layer to assign the data access layer repositories.

    I would really like to create my own dependancy mapping containers for this but I'm wondering if I need to be aware of any problems that may need to be addressed if used in the integrated pipeline? Will IIS cause any problems because of application pooling? Also will this be an issue in a clustered server configuration?

    Note: I'm aware that DI frameworks would most likely handle any concerns for me but I really would like to use my own implementation if it's not going to be too much of a hassle.

    Any advice would be greatly appreciated.

    Friday, October 19, 2012 5:30 AM

Answers

  • User-952121411 posted

    Will IIS cause any problems because of application pooling? Also will this be an issue in a clustered server configuration?

    I have never heard or seen of any such issue. If there was any issue with IIS and application pooling, it would not single out DI and constructor injection to pick on and have issues across the application. Typically IIS becomes a concern with things like load balancing and preserving session but there are methods to solve this problem too (i.e. state server).

    I'm aware that DI frameworks would most likely handle any concerns for me but I really would like to use my own implementation if it's not going to be too much of a hassle.

    To overuse a cliche, "why re-create the wheel"? There are a slew of mature, stable, and documented DI frameworks that will still satisfy your appetite for a challenge and a beautifully created application without starting from scratch. Have a look at the following to see what I mean:

    List of .NET Dependency Injection Containers (IOC):
    http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2012 9:09 AM
  • User-210056564 posted

    We once did a project on creating a tiny DI framework. The toughest think was to handle the lifetime of the generated objects. Best of luck with your project :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 29, 2012 10:32 PM

All replies

  • User-952121411 posted

    Will IIS cause any problems because of application pooling? Also will this be an issue in a clustered server configuration?

    I have never heard or seen of any such issue. If there was any issue with IIS and application pooling, it would not single out DI and constructor injection to pick on and have issues across the application. Typically IIS becomes a concern with things like load balancing and preserving session but there are methods to solve this problem too (i.e. state server).

    I'm aware that DI frameworks would most likely handle any concerns for me but I really would like to use my own implementation if it's not going to be too much of a hassle.

    To overuse a cliche, "why re-create the wheel"? There are a slew of mature, stable, and documented DI frameworks that will still satisfy your appetite for a challenge and a beautifully created application without starting from scratch. Have a look at the following to see what I mean:

    List of .NET Dependency Injection Containers (IOC):
    http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2012 9:09 AM
  • User-1002157272 posted
    Load balancing was what I'm most concerned with. I guess I won't be able to know for sure until I test it for compatibility issues. I'll check your link out of curiosity but as I said I'm not really interested in using a DI framework. I really dislike the idea of runtime dependency settings being loaded from XML or databases. The performance is simply unattractive and I more or less have a need to reinvent the wheel for my scenario. I can't get into specifics for privacy reasons but long story short, everything in this project is leveraging cutting edge technologies and is only really using an extremely stripped down implementation of the asp.net framework for basic functionality. Everything else is handled within its own proprietary framework.
    Wednesday, October 24, 2012 7:45 PM
  • User-210056564 posted

    We once did a project on creating a tiny DI framework. The toughest think was to handle the lifetime of the generated objects. Best of luck with your project :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 29, 2012 10:32 PM