ardalis / pluralsight-ddd-fundamentals

Sample code for the Pluralsight DDD Fundamentals course by Julie Lerman and Steve "ardalis" Smith
MIT License
896 stars 314 forks source link

SharedKernel project is not a SharedKernel #53

Closed mayerraphael closed 1 year ago

mayerraphael commented 1 year ago

From the original documentation:

Designate with an explicit boundary some subset of the domain   model that the teams    
agree to share. Keep this kernel small.

SharedKernel is about sharing a domain models across bounded context. Not about sharing infrastructure code. The shared kernel in this project is rather a Common/Core and has nothing to do with Domain Driven Design. DDD does not care about infrastructure.

I know people have many different opinions on this topic, thanks to the vagueness of the original source. Still, a dependency to MediatR and other infrastructure libraries in the SharedKernel project seems wrong.

ardalis commented 1 year ago

It's true DDD shouldn't care about infrastructure, and you'll find there are no external dependencies (to out-of-process systems, etc) in the SharedKernel. You could argue that things like common base classes and utilities might be better off in a differently-named but similarly-consumed library, but I've never seen any value in doing so. In my experience the number of actual domain model types that should be shared between bounded contexts is vanishingly small - maybe a common User class for instance. So having just that 0-2 types in one library and then having a separate library with the base types, etc. seems like overkill. Hence, just the one library.

mayerraphael commented 1 year ago

thanks for your opinion.