lundi 14 mars 2016

Where is i must put interfaces and implementations

I have Domain assembly and SqlServerRepository assembly.

SqlServerRepository assembly has a reference on Domain assembly, Domain assembly doesn't have reference on other assemblies.

Domain assembly has interface IRepository (and others for repository), because domain logic works only with interface types and doesn't think about concrete types.

SqlServerRepository assembly implements interface IRepository (which is contained in the Domain assembly).

And it's ok, I can mock IRepository, can use OracleRepository implementation and another...

But I think I have some architecture problem...

  1. SqlServerRepository can't work without the Domain assembly
  2. On another hand, if I put interfaces in SqlServerRepository assembly, the Domain will not work without SqlServerRepository assembly, and if I create OracleServerRepository assembly, I must use SqlServerRepository too, because I put the interfaces in the SqlServerRepository and Domain alredy uses them.
  3. Where should I map database objects to domain? In the SqlServerRepository or in the Domain assembly?

I thought about an assembly which contains only interfaces, and Domain and SqlServerRepository reference it, but I think it is overhead for my project (microservice)

So, what must I do?

Aucun commentaire:

Enregistrer un commentaire