为什么我们使用不同的体系结构,如3层,n层和mvc而不是我们可以直接从代码中连接数据库? [英] Why we use different architectures like 3 tier,n tier and mvc instead of that we can directly connect the database from code behind?

查看:34
本文介绍了为什么我们使用不同的体系结构,如3层,n层和mvc而不是我们可以直接从代码中连接数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.net中使用的不同体系结构的用途是什么,而不是直接连接到数据库?

what is the use of different architectures used in .net instead of directly connect to the database?

推荐答案

1。管理数据独立于物理存储

2.迁移到新的图形环境更快

3.可以在演示级别上进行更改而不影响其他两个(业务或数据访问层)

4.由于每个层都是独立的,因此可以使用不同的开发人员集合

5.由于客户端没有直接访问权限数据库业务逻辑更安全

6.当一层失败时,没有数据丢失,因为访问另一层总是安全的。



可扩展性:每个层都可以水平扩展。例如,您可以在三个服务器之间对Presentation层进行负载平衡,以满足更多Web请求,而无需向Application和Data层添加服务器。



性能:因为Presentation tier可以缓存请求,最小化网络利用率,并减少应用程序和数据层的负载。如果需要,您可以对任何层进行负载平衡。



可用性:如果应用层服务器关闭且缓存足够,表示层可以使用缓存。



参考文献: one [ ^ ]& 两个 [ ^ ]



- KR
1. Managing data is independent from the physical storage
2. Migration to new graphical environments is faster
3. It is possible to make changes on the presentation level without affecting the other two (business or data access layer)
4. As each tier is independent it is possible to use different sets of developers
5. Since the client doesn’t have direct access to the database business logic is more secure
6. When one tier fails there is no data loss, because you are always secure by accessing the other tier.

Scalability: Each tier can scale horizontally. For example, you can load-balance the Presentation tier among three servers to satisfy more Web requests without adding servers to the Application and Data tiers.

Performance: Because the Presentation tier can cache requests, network utilization is minimized, and the load is reduced on the Application and Data tiers. If needed, you can load-balance any tier.

Availability: If the Application tier server is down and caching is sufficient, the Presentation tier can process Web requests using the cache.

References: one[^] & two[^]

-KR


因为它将问题分开,并且更容易规划,实施和管理大型任务。



当你交易时对于一个小工作来说,模块化事情似乎并不重要,但项目越大,就越有必要。如果您只是在整个代码中直接访问数据库,那么(比如说)更改数据库以将表拆分为两个,或者从MySql更改为MsSql,这是一项巨大的工作。如果您以结构化的方式工作(这种架构迫使您以较小或更大的方式执行),则更改将限于较小的方法集,并且更易于管理和测试。如果将层分成单独的组件,则可以更换整个组件,而其他层甚至不会注意到!



想一想:为什么你不是把所有文件都保存在一个文件夹里吗?为什么要以分层方式组织它们?这是一回事:对于少量文件,很容易找到你想要的东西。但是当你开始获得大量数据时,将它们组织成分层文件夹 - 项目,通信,手册,视频和音乐 - 也可以组织这些文件夹,因此项目有五个文件夹,每个文件夹都有一个单独的文件夹工作,或者你的MP3收藏由乐队组成,然后是专辑,然后每首歌使得它更容易使用。
Because it separates concerns, and makes it easier to plan, implement, and manage large tasks.

When you deal with a small job, it doesn't seem important to "modularize" things, but the larger the project gets, the more necessary it is. If you just access the DB directly throughout your code, it's a massive job to (say) change the database to split a table in two, or change from MySql to MsSql say. If you work in a structured manner (which architectures force you to do in a lesser or greater way) then the changes become limited to a smaller "set" of methods and are easier to manage and test. If you separate the "tiers" into separate assemblies, then it's possible to replace a whole assembly and for the other layers to not even notice!

Think about it: why don't you keep all your files in a single folder? Why organise them in a hierarchical manner? It's the same thing: for a small number of files, it's easy to find what you want. But when you start to get to a significant number, having them organised into "layered" folders - projects, correspondence, manuals, videos, and music perhaps - and having those also organised, so "projects" has five folders, each with a separate "job" in, or your MP3 collection organised by band, then album, then each song makes it a lot easier to work with.


这篇关于为什么我们使用不同的体系结构,如3层,n层和mvc而不是我们可以直接从代码中连接数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆