I was looking at a library called Automapper. I am having a few concerns with this:
We dont want to expose our data model (GOOD). Why should the datamodel closely resemble your DB?
using lightweight DTOs instead of your entities. (GOOD)
Now I need to map my entities to these DTOs. Am i respecting the DRY principle??
One could argue that DTOs violate DRY, but if it makes sense for your situation then I wouldn't think twice about it.
DRY, like most programming best practices, isn't a silver bullet. Sometimes you have to compromise. In this case, I'd argue that violating DRY is perfectly acceptable in order to prevent issues that can arise from leaking your domain details to callers that don't need it (e.g. N+1 lazy-loading performance issues).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With