分离逻辑和UI [英] Separation of logic and UI

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

问题描述

我明白我应该把业务逻辑和UI分开,但是我不知道我现在在做什么违反了这个规则。



设计我的财务计划的表格结构。我有一些困难可视化一些部分,所以我嘲笑一些屏幕,以帮助我整理所有将需要的东西,以及如何组合在一起。我真的认为这是有帮助的,我相信我的模式是坚实的,但是我开始想知道是否也许我已经愚弄自己,认为使用模拟屏幕来帮助是真的伤害了我。



我使用模拟屏幕自动出错?



或者有人可以解释潜在的陷阱,以确保我



谢谢。

解决方案

这是两个不同的东西。如果您使用模型来更好地了解应用程序发生了什么,或者设计表结构,那没关系。您只是计划应用程序的工作原理。



但是,如果您采用模型,并开始将代码放在其中,而不仅仅是显示数据。例如,添加SQL语句以检索信息,或添加任意数量的语句来更改数据,那么您将混合逻辑与视图或UI。如果您对更详细的技术说明感兴趣,请阅读以下文章:
http://www.cs.usfca.edu/~parrt/ papers / mvc.templates.pdf


I understand that I should keep my business logic and UI separate, but I don't know if what I'm doing now violates that rule.

I'm designing my financial program's table structure. I've had a little trouble visualizing some parts, so I mocked up some screens to help me sort out what all will be needed and how things fit together. I really think it's helped, and I believe my schema is solid, but I started wondering if maybe I've fooled myself into thinking that using the mock-up screens to help is ok when it's really hurting me.

Have I automatically gone wrong by using the mock-up screens?

Or could someone explain the potential pitfalls so I can make sure I'm not going down the wrong path?

Thanks.

解决方案

Those are two different things. If you're using mockups to get a better understanding of what's going on with the application, or to design the table structure, that's fine. You're just planning how the application is going to work.

If, however, you take the mockups and start putting code in them that does any more than displaying data... for example, adding a SQL statement to retrieve information, or adding any number of statements to alter the data, then you are mixing logic with views or UI. That makes your overall code hard to maintain, among other things.

If you're interested in a more detailed technical explanation, please read the following paper: http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

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

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