News for hackers. Stuff that matters.
Re:Software Architecture Patterns: 5 minute read by kenniskrag on Thursday October 28, 2021 @10:52AM (#29026780)
I usually create "Service" classes in the domain layer, which use Repositories. These repositories are a wrapper for the DbContext to allow unit testing. Where do you put your domain logic? Do you have a domain model or is your persistence model your domain model?
Re:Software Architecture Patterns: 5 minute read by brainwipe on Friday October 29, 2021 @05:16AM (#29036725)
Domain model is the peristence model. Splitting them apart is often known as an anemic domain model (in Domain Driven Design).

All the domain logic is on the entity. So our command handlers (akin to your service methods) look like:

1. Load entity 2. Call method on entity, passing in data 3. Save entity 4. Raise events

So we only unit test 2. because that's the domain code. Loading entities from the dbContext is someone else's code. So is saving. So is raising events.

If your entity class gets big, split out the functionality into other classes so that you end up with a fair portion of bodyless methods.

Hope this is making sense!

Re:Software Architecture Patterns: 5 minute read by telchar on Thursday October 28, 2021 @02:38PM (#29029699)
Can you expand on how those repositories are written and how you use them for unit testing?