Interfaces

Interfaces are justified only in two cases: if it’s for mocking, or there are multiple implementations. Creating an interface with a single implementation does not increase decoupling or maintainability. Best case it just decreases the readability of code. Worst case, it gives some false belief on it adding some value.

Layers of abstraction

There is a need of having layers of abstraction, but a very limited amount of them. Three is enough - one for domain, one for application and one for services. Other layers are just a subset of application, sitting within one of this three layers.

MediatR

Why even would you use it? I was trying to find some information on why use MediatR.

From positives:

  • in theory, it provides decoupling
  • in practice, it reduces the amount of injected instances into controllers

From negatives (in practice only):

  • it invisibly couples a distant pieces of code (there are no explicit usages listed by IDE)
  • it spreads the application logic all over the place, significantely decreasing a readability of code

Final verdict: do not use.

Update after some thoughts:

If doing a real DDD with separate workflows and messages to send data between workflows, MediatR helps with doing a service-oriented monolith. What it means is that as a pro you get ability to subscribe to the same event from multiple events.