我想知道哪个是我能在这里使用的最佳设计模式,为什么? [英] I would like to know which is the best design pattern I can use here and why?

查看:53
本文介绍了我想知道哪个是我能在这里使用的最佳设计模式,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为个人数据管理设计一个winform应用程序。



它有10个winform表格,从登录表格到永久地址对话框,临时地址对话框,车辆详细信息对话框1,车辆详细信息对话框2,旅行费用对话框,其他经历对话框等。



因此,从每个对话窗口我都可以选择返回和下一步导航。



每个对话框包含近10到15个字段。



我想知道哪个是最好的设计模式我可以在这里使用,为什么?



我尝试过:



我试过的是每当用户导航,当前表单我保存为blob并且在每个对话框的初始化函数中我通过读取相应的blob来填充字段。

解决方案

我认为您的方法类似于 Memento [ ^ ]设计模式,在我的opinoin中,是正确的。


你的想法听起来你是一个初学者 - 为什么不先给一些时间来理解不同的模式 - 最好是顺应趋势,因为你会发现更多的例子 - 所以在你的情况下我会猜测数据绑定和更新是重要的事情。所以我使用MVVM模式 MVVM模式 [ ^ ]和WPF作为客户端技术,也许是UniversalApp?您会发现这些技术的大量样本: GitHub - Microsoft / Windows-universal-samples:通用Windows平台的API示例。 [ ^ ]



https://github.com/Microsoft/WPF-Samples

I need to design a winform application for personal data management.

It has 10 winform forms starting from login form to Permanent address dialog, Temporary address dialog, Vehicle details dialog1, Vehicle details dialog2, Travel expence dialog, Misc expence dialog etc.

So from each dialog window i am giving provision to go 'Back' and 'Next' navigation.

Each dialog contains almost 10 to 15 fields.

I would like to know which is the best design pattern i can use here and why?

What I have tried:

What i have tried is whenever user navigate, current form i am saving as a blob and in the initialize function of the each dialog i am populating the fields by reading the respective blob.

解决方案

I think your approach resembles the Memento[^] design pattern and, in my opinoin, is correct.


Your idea sounds like you are a beginner - why not give some time in understanding different patterns first - best is to go with the trend because you will find more examples - so in your case I would guess data-binding and updating is the important thing. So I'd use a MVVM pattern The MVVM Pattern[^] and WPF as Client Technology, maybe a UniversalApp? You will find tons of samples for these techs: GitHub - Microsoft/Windows-universal-samples: API samples for the Universal Windows Platform.[^]
or
https://github.com/Microsoft/WPF-Samples


这篇关于我想知道哪个是我能在这里使用的最佳设计模式,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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