Comments (11)
The rules I follow when using Clean DDD Architecture (as this sample does) are:
-
Minimize dependencies in ApplicationCore; do not depend on anything that depends on infrastructure. So, no references to EF or SendGrid or any other packages that are about out-of-process communication. This keeps ApplicationCore easy to test and easy to depend on without tying the app to a particular infrastructure decision.
-
Making sure to follow rule 1, if you can move something into ApplicationCore, you probably should. This mostly pertains to Services. If you have a Service that sends emails using direct calls to System.Net or some SendGrid client library, it should probably go in Infrastructure since you don't want those dependencies in ApplicationCore. However, if you have a Service that acts at a slightly higher level of abstraction and it "sends emails" by calling an injected interface like ISendEmail, and performs other logic that has no external dependencies, then this service could certainly live in ApplicationCore (since it has no dependencies on external infrastructure or specific implementation details).
Does that help?
from eshoponweb.
Yes, certainly. This follows the Dependency Inversion Principle. Concrete implementations (in Infrastructure) should depend on abstractions (interfaces in ApplicationCore), not vice versa.
from eshoponweb.
Infrastructure has a compile time dependency of Application Core, and Application Core has a run time dependency of Infrastructure. Runtime dependency is mentioned in the ebook, but Application Core seems to be isolated from Web App and Infrastructure dependencies. Sort of confused, whether we should have that run time dependency at all to the Application Core.
from eshoponweb.
I don't see any issues with how it is implemented. All ApplicationCore, Web, and even Infrastructure needs to know about is IAppLogger. If you need to log in ApplicationCore, you'd inject IAppLogger into your classes. They shouldn't know or care how it is implemented in Infrastructure.
from eshoponweb.
Correct, what @yarrgh said.
from eshoponweb.
So, is it OK to have a Run time dependency to ApplicationCore from Infrastructure?
from eshoponweb.
Infrastructure has a compile time dependency of Application Core, and Application Core has a run time dependency of Infrastructure.
Exactly.
Runtime dependency is mentioned in the ebook, but Application Core seems to be isolated from Web App and Infrastructure dependencies.
This is by design. The fewer dependencies the ApplicationCore project has, the easier it is to test.
Sort of confused, whether we should have that run time dependency at all to the Application Core.
If you didn't have any runtime dependency, that would imply that the only thing in ApplicationCore was abstractions (e.g. interfaces, abstract base classes). There would be 0 lines of actual executable code. Thus, nothing to test. You need to have your business/domain logic live somewhere. If there were no executable code in ApplicationCore, then your domain logic would either be in Infrastructure (highly coupled, harder to test) or in UI (also not the right place for it).
from eshoponweb.
The eBook has some references for more reading on Onion Architecture, Clean Architecture. You might benefit from reading those. If you have Pluralsight, I suggest checking out my courses on N-Tier C# apps, Domain-Driven Design Fundamentals, and SOLID Principles of OOP. I can send you a 30-day free pass if you need one. HTH.
from eshoponweb.
Thanks Steve. I do have a Pluralsight subscription, I will checkout those courses. I am keen on DDD and Clean architecture, was trying to construct something that abide by the Clean DDD Architecture.
@yarrgh Exactly, core principle is to make the dependencies loose and flexible. Thanks.
from eshoponweb.
Do I understand correctly that if I have IEmailSender, IPushNotificationSender and IUriComposer interfaces in ApplicationCore then EmailSender and PushNotificationSender implementations should be in Infrastructure project (since they depend on 3rd party libs) and UriComposer should be in ApplicationCore (does not depend on libs)? Or is it because EmailSender and PushNotificationSender communicate with external services?
from eshoponweb.
It is clear now. Thanks Steve!
from eshoponweb.
Related Issues (20)
- OBE
- Verify devcontainer for codespaces debugging HOT 6
- Modernize to .NET SDK Containers
- Inconsistent naming of async methods HOT 1
- How to connect to the postgres instance from the host ? HOT 1
- Shopify manager HOT 2
- public api get catalog brands throws error HOT 1
- How to debug this project using VS Code? HOT 1
- Architect Modern Web Applications edition 7th not available as PDF HOT 2
- incorrect about section in github description HOT 1
- Inject IHttpContextAccessor to CatalogContext's constructor will be destoryed when RevokeAuthenticationEvents.cs handle about CatalogContext's data
- The style class prefix "col-xs-*" didnt work in cshtml files. HOT 1
- Changelog for the latest version, updated to .NET 7, is not available in the wiki page HOT 4
- Update to bootstrap 5
- .NET 8 Updates HOT 5
- Facing issue when deploying the application on azure app service HOT 2
- I am not able to deploy the application to Azure from Visual Studio Code HOT 1
- I'm not able to update in memory database HOT 1
- Update NuGet packages to latest versions HOT 1
- Revalidate AZD HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eshoponweb.