简体   繁体   English

n层体系结构中可以为应用程序提供哪些额外的层?

[英]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). 我知道什么是三层体系结构(包含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 ... 请帮我 ...

C# is no different from other (imperative) programming languages. C#与其他(命令式)编程语言没有区别。 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. 如果使用的是C#,则可能是某种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. 此层是否“正确”是一个颇有争议的问题,通常取决于您是否订阅DDD阵营。 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). 我通常最终会默认创建它们,因为它也有助于测试使模型与持久性脱钩(并允许轻松注入模拟)。

A Common tiered architecture makeup: 常见的分层体系结构组成:

  • Core Layer 核心层
  • Infrastructure 基础设施
  • Presentation 介绍

Broken down even further, these 3 layers can have their own granular layers. 进一步细分,这3层可以有自己的颗粒层。

Core Layer 核心层

  • Domain Models 领域模型
  • Enums 枚举

Infrastructure 基础设施

  • Repositories 储存库
  • Data Transfer Object Models 数据传输对象模型
  • Services 服务
  • Unit of Work 工作单位

Presentation 介绍

  • MVC Project MVC项目
  • Web API 网络API

I guess to answer you question, I could throw a layer in between the infrastructure and presentation layer and have a Testing layer. 我想回答您一个问题,我可以在基础架构和表示层之间放置一个层,并具有一个测试层。 Just keep in mind that by layering the application architecture like this by using the file structure is really only beneficial if you follow SOC and SOLID principles in your code. 请记住,只有在您的代码中遵循SOC和SOLID原则的情况下,通过使用文件结构对应用程序体系结构进行分层才真正有益。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM