1

Let me start of by saying that by "worth it" I don't mean "remove DI and interfaces" and such.

What I mean is to place the code in separate class libraries. Like done in the Onion architecture - which I like very much.

The problem is that the ASP.NET project is the bootstrapper when it really it should just do web presentation stuff. It gets even worse when using Identity because the ApplicationUser class is tightly coupled with Entity Framework. Because now your Core depends on EF. Which is not what N-Tier is all about.

So my question is. Is separating code into different class libs worth it when doing ASP.NET?

1
  • N-tiers is about having application layers physically separated and communicating over the network. It is not about separating code into class-libraries.
    – JacquesB
    Commented Jun 27, 2015 at 12:28

1 Answer 1

4

Separating code into class libraries (ie. seperate assemblies) can improve design because you can manage dependencies clearly - eg. you can ensure the frontend have a reference to the data access layer but not the other way around. .Net allows circular dependencies between classes, but not between assemblies, and circular dependencies between layers should be avoided. There is no big cost to creating several projects in VS, so I would say it is definitely worth it.

But this is not n-tier architecture. The tiers in n-tier are physically separated (on different servers) and communicate over network. Of course this introduces additional complexity since each layer needs a service interface and network stack etc., so this is only worth it if you have specific requirements like the ability for separate independent frontends to access the same business logic layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.