Search code examples
c#architecturemulti-layern-layer

What extra layers can there in n-layer architecture for an application?


i studying on software architecture principles.
i understood that what is three layer architecture (contains Presentation-Business -Data Access).
but anybody has any idea or extra layers for doing it for example someone do it by extra layers such as 'Service' layer 'Infrastructure' layer or other layers etc.
are there any extra layers for doing it?
I'm confused about doing it.
please help me ...


Solution

  • C# is no different from other (imperative) programming languages. Your exact architecture is often dictated by the framework in use. If you are using C#, it's likely some flavor of ASP.NET MVC. This is a good overview.

    Often, between the model and controller a service layer is introduced to encapsulate some business logic and transaction flows. Whether this layer is "correct" or not is a matter of quite a bit of debate, and generally depends on whether you subscribe to the DDD camp or not. Realistically, if you have lots of complex business logic, externalizing the logic into a service layer increases the testability, at the cost of decreasing the real-world modeling ability of your model layer. For pragmatic, testing purposes, the service layer often ends up being the source of most of your business logic.

    Repository or Data-Access layers are separated from model layer, and are very useful if your domain persistence hits a certain level of complexity. I usually end up creating them by default as it also helps with testing to decouple the model from their persistence (and allows easy injection of mocks).