MVC - 关注点分离 [英] MVC - Separation of Concerns

查看:131
本文介绍了MVC - 关注点分离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是个新手。我想请教一下MVC模型分离关注。我读了几MVC的教程,但我还没有各自的模型,视图和控制器的角色有充分的了解。

I'm a newbie. I want to ask about the MVC model for separation of concerns. I have read up a few MVC tutorials but I don't yet have a full understanding of the roles of each of the Model, View and Controller.

例如说,我写了一个用户监控投资组合的应用程序。我想登陆页面显示基于不同标准的投资名单,例如人们可以根据投资金额的投资名单,另一个可以责令其基于投资业绩。

For instance say I am writing an application for a user to monitor a portfolio. I would like the landing page to display lists of investments based of different criteria, for instance one may list investments based on amount invested, another may order it based on investment performance.

我的问题是,按照我应该在哪里写的逻辑生成列表的设计模式;在模型,视图或控制器?

My question is, in accordance with the design pattern where should I write logic for generating the lists; in the Model, View or Controller?

还有任何asp.net MVC的例子展示关注点分离是多少AP preciated。

Also any asp.net MVC examples demonstrating seperation of concerns is much appreciated.

在此先感谢球员。

推荐答案

在重复自己的风险,我会指示你我给<一个答案href=\"http://stackoverflow.com/questions/1242908/in-english-what-really-is-model-view-controller/1242962#1242962\">in这个线程。 <一href=\"http://stackoverflow.com/questions/1242908/in-english-what-really-is-model-view-controller\">The整个主题可能是值得你花时间,因为是几十人对堆栈溢出的。

At the risk of repeating myself, I'll point you to the answer I gave in this thread. The entire thread is probably worth your time, as are dozens of others on Stack Overflow.

要打破它简单:

控制器 - 控制应用程序的流程,使有关数据决定。

Controllers - control application flow and makes decisions about data.

模式 - 执行业务逻辑

Models - perform business logic.

查看 - 产生输出

有关你的特殊情况,你将要产生在查看您层名单。使用模板来创建表结构,并从模型层读取的数据填充。

For your particular situation, you will want to produce your lists in the View layer. Use templates to create your list structure, and fill them with data fetched from the Model layer.

我不是一个asp.net程序员,所以我不能给你一个可靠的例子,但有一个到处寻找其他SO线程。

I'm not an asp.net programmer, so I can't give you a reliable example, but have a hunt around for other SO threads.

这篇关于MVC - 关注点分离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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