I have some questions about the "best" underlying architecture of software projects. I know, that there are different similiar posts but I'm really confused because it seems that everybody is telling something completely different or often with such abstract example that are difficult to apply to real world projects.

In Detail, the terms Rich Domain Model and 3-layer-architecture are consufing me.

So, I,ll develop a WebApi project which will be consumed by multiple clients (iOS, Android, Web (maybe MVC or a SPA)).

I thought the architecture should look something like this (with an Anemic Domain Model):

  • DAL (persistence layer, only methods for retrieving and writing into DB, working with POCOs)
  • Business Logic Layer / Service Layer (should contain all business logic, also working with the same POCOs(?) and doing operations like calculation on them)
  • WebAPI (not sure which methods should stay here, Should WebAPI expose all methods from Business Layer? Sounds like a lot of duplicated code)

  • Clients (only communication with WebAPI)

Now I've heard a lot about the Rich Domain Model in the past and that this approach is better where the model contains all business logic.

I'm now really unsure how this fit into the 3 layer Architecture. Is the BLL now obsolote?

Or does it have a BLL with methods like this (organizing and calling the model methods)

public void Transfer(BankAccount account1, BankAccount account2, int amount)
{
    account1.Widthdraw(amount);
    account2.AddMoney(amount);

    Mail.SendInfoMail();
}

And where should Methods like Excel-Export (Application Logic) belong?

Maybe someone is able to improve my understanding oh these concepts.

Another question is, which objects gonna be used in different layers? Should i work with the domain objects in all upper layers and only return DTO's from WebAPI for the clients to work with? Don't want to map each object to another object in other layers.

Thank you!

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.