需要创建一个“选择你自己的冒险”类型指南 - 最佳使用方法
基本上需要询问用户一系列问题并收集信息。每个问题都可能对以后的不同问题产生影响。另一个例子是涡轮税的网络界面,在某些“?”上回答“是”可能会引发未来的问题。
似乎这在软件中是一个相当常见的问题,所以我想我是在问是否有任何现有的解决方案/设计模式可以提供帮助。有点像状态机,但我认为这过于简单化了。
Basically need to ask user a set of questions and gather information along the way. Each question could have impacts on different questions down the road. Another example would be turbo tax's web interface, answering yes on some ?s may trigger future questions.
Seems like this would be a fairly common problem in software so I guess I'm asking if there are any existing solutions/Design Patterns out there that could help. Kind of seems like a state machine, but I think that is an oversimplification.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
状态模式
State pattern
看这张图片,它有助于选择正确的字体,称为 所以你需要字体(大图!)。
它会问您许多问题,并在某些时候建议您一个或多个答案。
据我了解,您想要创建一些类似但交互式的内容,并且涉及另一个领域。
因此,您需要使用分支节点和叶节点构建类似的图。使用复合模式可以非常方便地完成此操作。如果您已经(知道)所有可能的问题(或者如果您知道在某个时候您将知道所有问题并且能够将它们手动添加到系统中),那么这就是正确的选择。
如果您想要更加动态和智能的东西,那么解决方案可能会因情况而异。
Look at this picture which helps with choosing correct fonts which is called So You Need a Typeface (big image there!).
It asks you numerous questions and at some point suggest you one or several answers.
As I understand you want to create something similar but interactive and about another domain.
So, you need to construct similar graph with branching-nodes and leaf-nodes. It can be done very conveniently with the Composite pattern. If you already have (know) all possible questions (or if you know that at some point you will know all of them and will be able to add them manually to the system) then it's the way to go.
If you want something more dynamic and intelligent then the solution can highly vary from case to case.