“纯粹的”MVC实现有用吗? [英] How useful is a 'pure' MVC implementation?

查看:107
本文介绍了“纯粹的”MVC实现有用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一家提供定制CRM类软件的公司工作。我们目前正在重新设计/重新开发该软件,希望它看起来更现代,更容易为未来的客户开发和定制。目前,定制每个新应用程序需要很长时间。

I work at a company that provides custom made 'CRM'-like software. We are currently redesigning/redeveloping the software with the hopes that it will look more modern and be easier to develop and customize for future clients. Currently it takes a long time to customize each new application.

有一种假设认为它需要这么长时间的原因是因为存在的业务逻辑数量很多'视图'层。在某种程度上,我可以保证这是真的,但症状并不总能可靠地指出原因。有一个建议是,如果我们只是将业务逻辑移动到控制器层并使用纯视图(我们使用java J2EE和struts),就像实现struts标签而不是调用bean层并在jsp上迭代对象 - 等等。

There is a presumption that the reason it takes so long is because of the amount of business logic that is present in the 'view' layer. To some extent I can vouch for this being true, but symptoms don't always reliably point out a cause. There was a suggestion that if we just move the business logic to the controller layer and use pure view (we use java J2EE and struts) as in implementing struts tags instead of calling the bean layer and iterating objects right on the jsp - etc etc.

在我开始提倡之前,我们继续这样做,我想了解其他人的想法。 MVC的纯粹实现(特别强调解耦控制器和视图)是否提供了更清晰,更易于开发和更改的代码库?

Before I start advocating we go forward with this, I wanted to get a feeling for what other people thought. Does a "pure" implementation of the MVC (especially emphasis on decoupling the controller and the view) provide a cleaner, easier to develop and change code base?

感谢大家的投入 - 这已经帮助了很多

推荐答案

你的目标应该是获得你的业务逻辑在一个地方。根据我的经验,如果你能做到这一点,你的代码库将更容易开发,维护和更改。

Your goal should be to get your business logic in one place. In my experience, if you can do that, your code base will be easier to develop, maintain, and change.

模型 - 视图 - 控制器是一种方法那一点,虽然在经典的MVC中,业务逻辑在(域)模型中,而应用程序逻辑在控制器中。

Model-view-controller is a way to get to that point, though in classic MVC, the business logic is in the (domain) model, while application logic is in the controller.

应用程序逻辑:如果用户的下一个检查日期在一周内(或过期),则显示计划检查屏幕,否则显示检查历史记录屏幕。

Application logic: if the user's next inspection date is within a week (or past due), show the 'schedule inspection' screen, otherwise show the 'inspection history' screen.

商业逻辑:以前检查失败的餐馆需要每六个月检查一次,海鲜餐馆必须每年检查一次,所有其他餐厅必须每两年检查一次。鉴于这家餐厅的最后一次检查,他们的下次检查何时到期?

Business logic: restaurants that have previously failed inspection need to be inspected every six months, seafood restaurants must be inspected every year, and all other restaurants have to be inspected every two years. Given this restaurant's last inspection, when is their next inspection due?

这篇关于“纯粹的”MVC实现有用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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