ForEvolve.Blog.Samples | Blog samples home - ForEvolve blog samples repository | Blog library
kandi X-RAY | ForEvolve.Blog.Samples Summary
kandi X-RAY | ForEvolve.Blog.Samples Summary
ForEvolve blog samples repository. A few samples are elsewhere, but this is the new centralized code sample repository.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ForEvolve.Blog.Samples
ForEvolve.Blog.Samples Key Features
ForEvolve.Blog.Samples Examples and Code Snippets
Community Discussions
Trending Discussions on ForEvolve.Blog.Samples
QUESTION
Note: This following is a similar question -- How to avoid Cyclic Dependencies when using Dependency Injection? -- but does not quite address my situation.
I am trying to develop an application architecture. I have currently identified the need for three distinct layers: API, Business, and Data Access. I am aiming for a loosely coupled, dependency injection design based on the one here: https://www.forevolve.com/en/articles/2017/08/11/design-patterns-web-api-service-and-repository-part-1/#the-patterns.
To summarize, NinjaController
(API) contains INinjaService
(BLL), which is implemented by NinjaService
(also BLL) which contains INinjaRepository
(DAL), which is implemented by NinjaRepository
(also DAL).
Since I am intending to use dependency injection, there is also a composition root, which would have to depend on all the above 5 definitions, so as to build the dependency graph. So far, everything makes sense.
Where I run into trouble is when I start to split things up into different assemblies. My current understanding (or lack thereof) is as follows:
- Assembly 0 contains the API implementation as well as the BLL interface, for an interchangeable BLL to implement.
Assembly 1 contains the BLL implementation as well as the DAL interface; thus Assembly 1 depends on Assembly 0 for its DAL interface.
Finally Assembly 2 contains the DAL implementation, which depends on Assembly 1's BLL interface.
However, Assembly 0 also contains the composition root, which depends on both the BLL and DAL interfaces, as well as the API, BLL, and DAL implementations.
So there is a cyclic project dependency between Assembly 0 and Assembly 1, where the root in 0 depends on the BLL implementation in 1 and the BLL implementation in 1 depends on the BLL interface in 0.
The best I can do so far is to have the BLL interface reside in Assembly 1 as well, but that seems to defeat the entire purpose of the interface.
So would someone kindly point out where my misunderstanding is, and if possible, how to achieve this design?
EDITFirst, I probably ought to have clarified my setup by means of more than a tag - I am using an ASP.NET Web API application layer (not .NET Core).
Second, to further illustrate my intended setup, something like the following (again based on the above cited example from forevolve.com):
Assembly 0 (see https://www.forevolve.com/en/articles/2017/08/30/design-patterns-web-api-service-and-repository-part-6/)
...ANSWER
Answered 2019-Nov-18 at 21:49Options:
- move dependency root into separate assembly (this way it is the only one that depends on all other assemblies
- use declarative initialization of the container (if one you use supports it) so you can define in some external configuration file what classes/interfaces to register and where they reside. Exact configuration depends on container you like
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ForEvolve.Blog.Samples
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page