C
C#2mo ago
Salight

Is it good practice to hide dtos in shared if it is not why and what should i do

No description
5 Replies
Sossenbinder
Sossenbinder2mo ago
I don't know, it depends on your case If they need to be shared? Yes If they don't have to be shared and are only ever referenced by one project? Then there's no reason Encapsulation also applies to project level
Salight
SalightOP2mo ago
i didn't understand what do you mean "by need to be shared" if it is possible can you give me a example of that
Sossenbinder
Sossenbinder2mo ago
Usually you put models or dtos in a shared project if you have two projects which want to use them, let's say project A and project B. If you don't want to run into an issue where A and B need to reference each other / end up as a cyclic dependency, it's a common practice to put shared models into a common project which A and B reference without having to reference each other But the main question is: Do you need shared models at all If only project A ever ends up using them, you can just leave them in A
Salight
SalightOP2mo ago
i am using in service,service contracts also in dal also in mvc but lets say i am just developing a api is this version of using does any harm to runtime
Sossenbinder
Sossenbinder2mo ago
This isn't necessarily a runtime related issue It's a matter of organization If you say that you need a shared dependency layer in your setup, it's fine

Did you find this page helpful?