代表应用程序导航

发布于 2024-07-17 14:59:20 字数 305 浏览 5 评论 0原文

我有一个包含很多页面的复杂应用程序。

每个页面可以有许多可能的路由到其他页面:“A”可以转到“B”或“C”,“B”可以转到“A”但不能转到“C”。 等等。

而不是在每个页面中嵌入“下一步去哪里”逻辑(恐怖!),我当然想将其封装在一个主要控制点中。 “A”不需要知道“B”或“C”。

更好的是,我想将问题减少到配置问题。

这不是一个特定于语言/框架的问题——这是如何最好(简单、实用)地表示和解释工作流逻辑的问题。

有人有过将应用程序中各点之间的复杂流程表示为可配置设置的经验吗?

I have a complex application with many pages.

Each page can have many possible routes to other pages: 'A' can go to 'B' or 'C', 'B' can go to 'A' but not 'C'. etc.

Rather than embed this "where to go to next" logic in each page (horror!) I of course want to encapsulate it in a main point of control. 'A' doesn't need to know about 'B' or 'C'.

Even better, I'd like to reduce the problem to a matter of configuration.

This isn't a language/framework specific question -- it's a matter of how best (simple, pragmatic) to represent and interpret Workflow logic.

Has anyone had experience representing a complex flow between points in an application as a configurable setting?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

一直在等你来 2024-07-24 14:59:20

您所描述的是一个非常经典的有限状态机。 您可以拥有状态(页面)、导航(转换),还可以拥有诸如进入/退出操作和转换条件之类的内容。

话虽如此,值得考虑一下您的导航,您是否只是想要动态添加到页面的导航选项列表,或者是否涉及一些额外的智能。 想一想何时导航有效、导航需要什么信息、您可能希望在下次导航时携带的数据等等。

我之前已经通过简单地使用 XML 创建了状态映射,例如:

<states>
  <state name="Open">
    <transition action="Close" state="Closed" />
  </state>
  <state name="Closed">
    <transition action="Open" state="Open" />
    <transition action="Lock" state="Locked" />
  </state>
  <state name="Locked">
    <transition action="Unlock" state="Closed" />
  </state>
</states>

What you describe is a pretty classic Finite State Machine. You have States (Pages), Navigation (Transitions), but also you can have things like entry/exit actions and transition conditions.

With that said, it's worth thinking about your navigation, do you simply want a list of navigation options dynamically added to the page, or is there some extra smarts involved. Think of when the navigation is valid, what information is required for the navigation, the data you might want to bring with you to the next navigation etc.

I've created state maps before by simply using XML, eg:

<states>
  <state name="Open">
    <transition action="Close" state="Closed" />
  </state>
  <state name="Closed">
    <transition action="Open" state="Open" />
    <transition action="Lock" state="Locked" />
  </state>
  <state name="Locked">
    <transition action="Unlock" state="Closed" />
  </state>
</states>
白首有我共你 2024-07-24 14:59:20

您也许可以使用 .NET 工作流基础之类的东西来巧妙地表示这一点。

You might be able to use something like the .NET work flow foundation to represent this neatly.

ι不睡觉的鱼゛ 2024-07-24 14:59:20

这基本上是一个状态机,其中每个页面代表一个状态,并且转换存储在您的配置中。 谷歌一下,你会得到可能有帮助的样本。

This is basically a state machine, where each page represents a state and the transitions are stored in your configuration. Google for that, you'll get samples which may help.

血之狂魔 2024-07-24 14:59:20

几乎每个 Web 应用程序框架都必须解决这个问题。 对于 java,请查看 Struts2、Spring MVC、Tapestry、Wicket 等以了解各种方法。 (XML 自然是在外部配置文件中捕获转换信息的常用方法。)

Pretty much every Web Application framework has to tackle this problem. For java, take a look at Struts2, Spring MVC, Tapestry, Wicket, etc. to see the various approaches. (XML is naturally a common method of capturing the transition information in an external config file.)

南笙 2024-07-24 14:59:20

Press On 涵盖了此类内容在一定深度上。 (在用户界面的设计和实现中使用状态机和状态图的显式表示。)

Press On covers this sort of thing in some depth. (Using explicit representations of state machines and statecharts in design and implementation of user interfaces.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文