Separation of logic and UI
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分离是一个架构原则。
Mock ups in and out of themselves do not hurt or help with UI/business logic separation. The way you implemented them might - to be more specific, if your business logic incorporates any code to directly display the mock-ups, you may be on shaky ground.
The best test of whether your UI is separate from business logic completely is try to envision that you need to re-write your code to support completely different display model (eg print text on a terminal instead of GUI, or do a native GUI vs. a web front end. Would such a change necessitate a major change in your business logic code? If so, you may want to separate more.
链接地址: http://www.djcxy.com/p/67684.html下一篇: 逻辑和UI的分离