MVC应用程序设计技巧
背景: 我加入了一个团队/项目,该团队/项目开发了一个 .net 自行开发的 MVC 类型架构,通过自行开发的 Ajax 调用将一系列 6 个屏幕中的数据保存到服务器上的上下文对象中以维护状态。
问题1: 这看起来就像使用 mvc 只是说我们使用 mvc 而不是 mvc 的做事方式。我觉得他们通过使用 mvc ajax 调用和服务器上下文对象来持久化状态来合成回发模型。有人可以解释一下真正的 MVC 方式来完成这个任务吗?!?!?
背景: 当向导启动时,它将用户数据从大型机加载到一个大对象中,但这是通过数据层抽象的。该对象拥有所有个人信息以及与特定用户相关的所有其他信息。这是一个静态对象,需要一些时间来加载,以至于如果进行另一个调用,它很可能仍在创建原始对象并在第二次调用时失败......所以他们有线程作为这个问题的答案。该用户对象是通过 Ajax 传递到上下文对象并在向导中单击下一个/上一个按钮时保留的对象。
问题 2: 这似乎是获取允许下一页/上一页的 6 页向导结果的糟糕方法。导航,我从未见过应用程序需要花费如此长时间才能在网络上加载,以至于需要实现线程以避免在对象尚未准备好使用时出现错误。在 stackoverflow 等网站上如何做到这一点?在这个应用程序中应该做什么?
background:
i came on board to a team/ project that have developed a .net home grown mvc type architecture with home grown Ajax calls to persist data in a series of 6 screens to a context object on the server to maintain state.
question 1:
this seems like using mvc just to say we use mvc and not the mvc way of doing things. it feels to me like they synthesized the post back model by using mvc ajax calls and server context objects to persist state. can someone explain the real MVC way for getting this done?!?!?
background:
when the wizard is kicked off it loads the user data into a large object from the mainframe, but this is abstracted via a data layer. this object has all the personal info and everything else pertaining to the particular user. this is a static object and takes some time to load, so much so that if another call is made it may very well be still creating the original object and fail on the second call... so they have threading as an answer to this problem. this user object is the one that gets passed via Ajax to the context object and persisted on each next/ previous button click in the wizard.
question 2:
this seems like a terrible way of getting the result of a wizard of 6 pages that allows next/ prev. navigation and i have never seen an app take so long to load over the web that threading needs to be implemented to avoid errors if the object is not ready for use. how would this be done on sites like stackoverflow and what should have been done in this app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答问题2; “向导”界面似乎是成为单个页面的完美候选者。为什么不在页面上只有 1 个可见 div 和 5 个隐藏 div 呢?然后无需重新加载即可返回/前进到向导屏幕。
回答问题1;从我们掌握的关于该应用程序的很少的信息中很难判断它是否忠实地实现了(至少在应用程序的某些部分)mvc 设计。当然,在每个项目中都使用的不仅仅是一种模式,而是多种模式。我不确定是否有人可以从给出的有限信息中判断使用 mvc 的尝试是否真实。
Answer to question 2; The "wizard" interface seems like a perfect candidate for becoming just a single page. Why not just have 1 visible div on the page, and 5 hidden divs? Then no reload necessary to go back/forward to wizard screens.
Answer to question 1; Its hard to tell from the very little information we have about the app if it faithfully implements (at least in some part of the application) the mvc design. Certinantly, In every project there are not jut one, but a number of patterns being used. I'm not sure anyone could say from the limited amount of information given, whether the attempt to use mvc is true-to-form or not.