Jeffrey Knight
Jeffrey Knight

Reputation: 5975

Representing application navigation

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?

Upvotes: 0

Views: 172

Answers (5)

Darius Bacon
Darius Bacon

Reputation: 15134

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.)

Upvotes: 0

alphazero
alphazero

Reputation: 27234

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.)

Upvotes: 0

Timothy Walters
Timothy Walters

Reputation: 16884

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>

Upvotes: 4

Lucero
Lucero

Reputation: 60236

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.

Upvotes: 0

oscarkuo
oscarkuo

Reputation: 10453

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

Upvotes: 0

Related Questions