在客户端-服务器体系结构中使用MVC(模型视图控制器) [英] Using MVC (Model View Controller) in a Client-Server architecture

查看:101
本文介绍了在客户端-服务器体系结构中使用MVC(模型视图控制器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为正在开发的应用程序选择一种设计模式.该应用程序主要基于客户机-服务器体系结构,其中客户机基本上是在服务器上读写数据.它不是Web应用程序,客户端将必须安装该软件可执行文件,然后与GUI进行交互,以便通过Internet协议与服务器(在另一台计算机上退出)进行通信.

I'm trying to choose an design pattern for an application that I'm developing. The application is primarily based on a Client-Server architecture where the Client basically reads and writes data to the Server; its not a Web-application however, The client will have to install the software executable and then interact with a GUI in order to communicate with the Server (which exits on a different machine) through an internet protocol.

由于该应用程序是基于与GUI的大量交互作用,因此我正在考虑使用MVC设计模式,因此,我很难确定服务器上应存在哪些部分以及客户端应有哪些部分.换句话说,可以在客户端保留 View (即边界GUI类和对象)和 Controller ,同时保留 Model (即Entity对象)在服务器端;这是应用MVC模式的可行或有效方法吗?我在这里朝正确的方向前进吗? 这有可能吗?我的意思是那些边界和控制类可以在没有访问同一机器或进程的Model类的情况下进行操作和执行吗?

Since the application is based on heavy interaction with a GUI, I was thinking about using the MVC design pattern, the thing is I'm having trouble deciding which part should exist on the Server and which on the Client side. In other words, is it ok to have the View (i.e the Boundary GUI classes and objects) and the Controller on the Client side, while leaving the Model (i.e the Entity objects) on the Server side; is this a viable or valid way of applying the MVC pattern ? Am I going in the right direction here ? Is this even possible ? I mean can those Boundary and Control classes operate and execute without having or accessing the Model classes on the same machine or process ?

我应该在客户端拥有全部内容(模型,视图和控制器类),然后仅通过协议与服务器数据库进行通信吗?

Should I have the whole thing (The Model, View and Controller classes) on the Client side and then just communicate with the Server database via the protocol ?

任何建议或评论都将受到欢迎.

Any suggestions or comments would be welcome.

推荐答案

在客户端-服务器设置中有很多实现MVC的方法.通常,您在客户端中放置的内容越多,您的应用程序就会变得更丰富"或更简单".因此,如果您决定使用MVC,那么真正的问题就变成了:我希望我的应用程序变得有钱吗?

There are a lot of ways of implementing MVC in a client-server setting. In general, the more stuff you put in the client the "richer" or "fatter" your application becomes. So, if you decide on using MVC, the real question for you then becomes: how rich do I want my application to be?

此外,您可以在一个应用程序中将多个MVC实例一起工作,分布在客户端和服务器上.

Also, you can have multiple instances of MVC working together in one application, distributed over client and server.

我会看的一些东西:

  • 网络:客户端和服务器之间需要传送多少数据?一个应用程序通常会发送多少个请求? (太多可能会使网络饱和或引起其他问题)

  • network: How much data needs to be shuttled between client and server? How many requests will an application typically send? (too much may saturate the network or cause other trouble)

响应能力:更高的响应能力可能需要您在客户端中投入更多

responsiveness: higher responsiveness can require you to put more in the client

安全性:通过网络传输的所有内容都不那么安全

security: everything that goes over the wire may be less secure

性能:如果需要高性能,则可能需要服务器上的组件

performance: if you need high performance, you may need components on the server

预期的负载:您可能决定在客户端放置更多组件来减轻服务器的负担,而不是例如将后端集群化

expected loads: you may decide to put more components client-side to offload the server, instead of clustering your backend for example

这篇关于在客户端-服务器体系结构中使用MVC(模型视图控制器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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