Experience, DotNet, Solutions

"An effective enterprise application should be divided into layers", An Enterprise application should have the flexibility, maintainability, scalability, testability, and extensibility. And to achieve this there are some techniques and principles like Separation of concern in layers and components and loose coupling. And if you are developing a web application, in order to make it secure and accessible, you need to distribute the application over multiple physical tiers. To ensure high performance and reliability, the application must be testable. Now I'm going to describe some architectural contexts just notice that I'm just talking about different kinds of layers and tiers and based on your solution and business you can apply each of them and you don’t need to have all of them in every enterprise application.

What is the layered architecture?

Layering is mostly about allocating specific responsibilities for the software. Maybe you have heard about "tier" instead of layer, it's OK! But tire mostly used for representing physical layout it's a project in the solution (in .NET), but the layer is not just a project in the solution although it could be. A layer is a conceptual element which could be consist of several tiers. So a tier could be a layer and vice versa but not in all the cases, in the real world several tiers could represent a layer. A Layer is completely separated from other layers and boundaries are supported by interface contracts. There are some Common layers that you can find in most of the enterprise application: infrastructure layer, Domain Layer, Application layer, Service layer, Presentation layer

Infrastructure and crosscutting Layer

"The Infrastructure Layer contains the standards and best practice designs for the underlying platform components", which enable the adequate functioning of all other layers. Infrastructure contains some basic and common configuration for all of the layers in the project such as Domain Events, Validations, basic Helpers, Unit Of work and etc. Maybe you have heard about the crosscutting layer, you can merge it with infrastructure layer. You can put authentication, authorization, Email, Logging, and service in crosscutting(if you have separated it from infrastructure).

Domain Layer

A domain is the heart and hardest part of the software. Designing the correct Domain model could guarantee software success. A domain is not just about some properties (domain objects) which represent fields of tables in the database. Complex business rules, behaviors should be solved in the domain layer. If you would like to know more about Domain Layer, you should go to the world of Domain Driven Design!

Data Access Layer and Repository

As I mentioned here before, Data access layer is something different from the repository, if you have a business object in your domain then you can have data access layer but if you have Aggregate(DDDesign) you can have Repository layer. The data layer provides access to external systems such as databases. You can use Microsoft Entity framework or Non-Microsoft open source ORM like NHibernate in your DAL or Repository layer.

Services Layer

"The services layer defines the composite set of functions that are required to create a reliable, secure, and transacted service." A set of specifications define the standard operating behavior for the services and enables them to be aggregated or composed into other applications. An application exposes some of its functionality for using other services or frameworks by service interface. By dependency injection tools you can make it lose coupled. It's so common to separate service interfaces from service implementation in other layers.

Business Layer

"Large enterprise applications are often structured around the concepts of business processes and business components." The business layer implements the business functionality of the application. Business logic should be separate from the presentation.

Presentation Layer

The presentation layer provides the application's user interface. It could be any framework, for example in .NET it could be Asp.net MVC, Asp.net WebForm, Silverlight, WPF and so on. Presentation layer talks to service layer interfaces.

About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns and I'm spending a lot of my time on architecture subject. Since 2008, I've been as a developer for companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the&nb
Read More