MVC 대 3 계층 아키텍처?
MVC와 3 계층 아키텍처의 기본적인 차이점은 무엇입니까?
3-tier 는 아키텍처 스타일 이고 MVC 는 디자인 패턴 입니다.
그래서 그것에서 다릅니다.
하지만 3 계층 아키텍처 스타일에서 mvc 패턴을 사용할 수 있습니다.
그래서:
프레젠테이션 계층 : MVC 패턴의 "컨트롤러 및 뷰".
비즈니스 계층 : MVC 패턴의 "모델 (데이터)".
데이터 액세스 계층 : 원래 데이터 액세스 계층.
대규모 응용 프로그램에서 MVC는 N 계층 아키텍처의 프레젠테이션 계층입니다. 모델보기 및 컨트롤러는 프레젠테이션에만 관심이 있으며 중간 계층을 사용하여 데이터 계층의 데이터로 모델을 채 웁니다.
MVC는 뷰가 프레젠테이션이고 컨트롤러가 비즈니스 논리이고 모델이 데이터 계층 (일반적으로 Entity Framework와 같은 DAL에 의해 생성됨) 인 전체 3 계층 아키텍처로 사용할 수도 있습니다.
이상적으로는 컨트롤러가 얇고 멍청하고 논리를 '비즈니스 구성 요소'에 전달하여 본질적으로 중간 계층이되기를 원합니다.
3 계층 아키텍처에서 계층 간의 통신은 양방향입니다. MVC에서 통신은 단방향입니다. 각 "레이어"는 왼쪽에있는 레이어에 의해 업데이트되고 차례로 오른쪽에있는 레이어가 업데이트된다고 말할 수 있습니다. 여기서 "왼쪽"과 "오른쪽"은 단지 예시 일뿐입니다.
3 계층 아키텍처는 일반적으로 3 개의 개별 네트워크 노드에 3 개의 개별 프로세스로 배포됩니다. 그러나 MVC는 단일 네트워크 노드에서 단일 프로세스로 배포하도록 설계되었습니다. (데스크톱 애플리케이션과 같음)
3 계층의 비즈니스 계층은 일반적으로 비즈니스 위임, 비즈니스 파사드, 비즈니스 객체, 서비스 로케이터, 데이터 전송 객체 등과 같은 유명한 패턴을 구현하는 여러 계층을 포함합니다. 그러나 MVC는 프레젠테이션 계층에서 사용되는 디자인 패턴 자체입니다.
3 계층의 목표는 클라이언트와 데이터베이스에서 비즈니스 로직을 분리하는 것이므로 여러 클라이언트 프로토콜, 높은 확장 성, 이기종 데이터 액세스 등을 제공합니다. 그러나 MVC의 주요 목표는 한 부분의 구현 변경이 다른 부분의 변경을 필요로하지 않는다는 것입니다. .
나는 마이클이 그의 대답에서 말한 것과 다른 접근 방식을 취합니다.
컨트롤러는 비즈니스 로직이 될 수 없습니다. 나에게 비즈니스 로직은 모델 계층에 속합니다. 그러나 뷰 (및 어느 정도 컨트롤러)와 프리젠 테이션 레이어의 일부인 모델은 MVC 애플리케이션에서 모델의 일부가 아닙니다. 모델은 MVC 애플리케이션의 핵심이자 영혼이어야하며 이것이 바로 MVC 애플리케이션에서 쉽게 구현할 수있는 도메인 기반 디자인의 핵심입니다.
동일한 프로젝트 (ASP.NET MVC) 내에 모델이있을 필요는 없습니다. 완전히 다른 프로젝트에 상주 할 수 있으며 여전히 애플리케이션의 모델로 작동 할 수 있습니다.
프레젠테이션 레이어 역할을하는 MVC 애플리케이션은 많은 계층이있는 거대한 프로젝트에서만 작동 할 수 있지만 질문자가 요청한 3 계층 아키텍처에서는 프레젠테이션 전용 레이어 역할을 할 수 없습니다.
그래서 우리는 MVC가 3 계층 아키텍처의 3 개 계층에서 2 개 (세 번째는 MVC 아키텍처의 일부가 아닌 데이터 계층 일 수 있음)를 만든다고 말할 수 있습니다.
감사.
3 계층 아키텍처 란 무엇입니까?
3 계층 (계층)은 사용자 인터페이스, 비즈니스 프로세스 (비즈니스 규칙), 데이터 스토리지 및 데이터 액세스가 독립적 인 모듈로 개발되고 유지되거나 대부분 별도의 플랫폼에서 유지 되는 클라이언트-서버 아키텍처 입니다. 기본적으로 계층 1 (프레젠테이션 계층, GUI 계층), 계층 2 (비즈니스 개체, 비즈니스 논리 계층) 및 계층 3 (데이터 액세스 계층)의 3 개 계층이 있습니다. 이러한 계층은 별도로 개발하고 테스트 할 수 있습니다.
DAL-데이터 액세스 계층 (연결 문자열 및 데이터 읽기 및 실행 프로세스 포함)
BOL-Bussiness Object Layer (쿼리 포함)
UI-사용자 인터페이스 (Forms & Code Behind)
자세한 내용 : 3 Tier 아키텍처
둘 사이에는 관계가 없습니다. MVC는 프리젠 테이션 레이어 패턴입니다. 전체 Model-View-Controller는 프레젠테이션 레이어에 존재합니다.
모델 은 View로 표시되거나 View에서 채워지는 데이터 (일반적으로 VO)를 보유하는 객체입니다.
컨트롤러 는 요청을 받고 (모델을 채울 수 있음) 서비스 계층을 호출하는 것입니다. 그런 다음 다른 (또는 동일한) 모델을 가져 와서 View로 다시 보냅니다.
보기 는 모델을 표시하고 사용자 입력을 캡처하기위한 구성 요소를 제공합니다. (일반적으로 웹 응용 프로그램의 템플릿 엔진이거나 데스크톱 응용 프로그램의 UI 구성 요소입니다.)
3 계층 (또는 n 계층) 애플리케이션에 대해 이야기 할 때 프레젠테이션 계층 (전체 MVC), 서비스 계층 (비즈니스 클래스) 및 데이터 액세스 계층으로 구성된 전체 애플리케이션의 아키텍처에 대해 이야기하고 있습니다.
서비스 계층 (및 그 뒤에있는 모든 것)은 MVC의 컨트롤러 뒤에 숨겨져 있습니다.
3 계층 아키텍처는 클라이언트 계층이 실제로 데이터 계층과 통신하지 않고 모든 통신이 중간 계층을 통과하는 선형입니다. 반면에 MVC는 뷰가 컨트롤러에 업데이트를 보내고 모델에서 업데이트를 수신하고 컨트롤러가 모델을 업데이트하는 경우 더 삼각형입니다.
( http://en.wikipedia.org/wiki/3-tier_architecture의 "MVC 아키텍처와 비교"참조 )
IMO는 3-Tier 아키텍처와 MVC를 직접 비교하지 않습니다 . 둘 다 결합에 사용되므로 동일한 렌즈를 통해 보는 경향이 있습니다. 개념적으로 함께 사용할 필요는 없습니다. MVC가 제공하는 것을 사용 하지 않는 3-Tier 아키텍처를 가질 수 있습니다.
정의 부분을 자세히 설명하지는 않지만 간단히 말해서 :
3-Tier 는 소프트웨어 아키텍처 접근 방식으로, 사용자 인터페이스, 비즈니스 프로세스는 논리, 데이터 계층은 독립적으로 개발되며 대부분 별도의 플랫폼에서 사용됩니다.
MVC 는 일정 기간 동안 소프트웨어 패턴에서 아키텍처 패턴으로 진화했으며 오늘날 모든 주요 프레임 워크에서 볼 수 있습니다.
Every Application has one are more of following Layers 1)Presentation Layer or UI Layer 2)Business Layer or Business Logic Layer 3)Data Access Layer or Data Layer
3-tier architecture usually has each layer separated by the network. I.E. the presentation layer is on some web servers, then that talks to back-end app servers over the network for business logic, then that talks to a database server, again over the network, and maybe the app server also calls out to some remote services (say Authorize.net for payment processing).
some times we requires more layers of the above type and more mechines then it is called as N-tier
MVC is a programming design pattern where different portions of code are responsible for representing the Model, View, and controller in some application. These two things are related because, for instance the Model layer may have an internal implementation that calls a database for storing and retrieving data. The controller may reside on the webserver, and remotely call appservers to retrieve data. MVC abstracts away the details of how the architecture of an app is implemented. Model on which model we wanted to build View means UI of the Application Contol Means the logic Which controls the Application
3-tier just refers to the physical structure of an implementation. These two are sometimes confused because an MVC design is often implemented using an 3-tier architecture.
My experience is that MVC is a just another "fad" term for badly-written 3-tier, where some of the communication jumps around the business layers, and thus the client and/or data layer also has business rules mixed in.
I hate code written like that - The term MVC must have been designed to confuse HR recruiters into thinking older programmers (who know it as "3-tier") are not matched for the job.
In MVC : MVC architecture is triangular: the view sends updates to the controller, the controller updates the model, and the view gets updated directly from the model
In Three Tier : A three tier architecture is the client tier never communicates directly with the data tier In a Three-tier model all communication must pass through the middle tier
Vikas Joshi Software Engineer
- 3-Tier is linear architecture. (Presentation tier -> Logic tier -> Data tier then Data tier -> Logic tier -> Presentation tier) But MVC is triangular architecture. (Control update View and Model. Model update View.)
- MVC can include in presentation tier (Mobile applications, Angular like js frameworks etc...) and Logic tier (J2EE, Laravel, etc...) in 3 tier architecture.
- Layers in 3 tier can implement in different network nodes. But typically elements in MVC implement in same network nodes.
I dont think MVC will change anything or help you build better or robust system. 3 tier architecture is successful and sufficient system. I/you can build very comprehensive and robust system in it. We all know a complex or real life website takes a lot of interaction between all the layers. I personally believe php for that reason has advatage over .net. If u ask a nerdy ass arrogant programmer to build a simple forum system in .net he will scratch his head over which control to use to render it. Then he will combine data grid with some repeater... But later on if u simply ask to add comment section or image, he will be like how the heck i do it? On the other hand in php... U can mix in html with server code to achieve any presentation layer easily... So dont brag about architecture as they have equal advatages and disadvantages. But ask what have you built?
참고URL : https://stackoverflow.com/questions/4577587/mvc-vs-3-tier-architecture
'Development Tip' 카테고리의 다른 글
SQL Server에서 VARCHAR / CHAR 대신 NVARCHAR / NCHAR을 언제 사용해야합니까? (0) | 2020.11.17 |
---|---|
SQL LIKE 절에서 SqlParameter 사용이 작동하지 않음 (0) | 2020.11.17 |
활성 메뉴 항목-asp.net mvc3 마스터 페이지 (0) | 2020.11.17 |
Google C ++ 스타일 가이드의 예외 없음 규칙; (0) | 2020.11.17 |
생성자에서 C ++ 개체 멤버 변수를 초기화하려면 어떻게해야합니까? (0) | 2020.11.17 |