Page Transition Conventions

Topics: Web Client Software Factory
Dec 20, 2006 at 11:43 AM
I've noticed that in a lot of the examples page flow is governed using calls such as;

x.NavigateTo("TheNextPage");

There's two things about this that are on my mind. Firstly, I'm not sure NavigateTo is the correct term - I would argue that the code should instead call method named "RaiseEvent" or "ApplyAction", something that implies the user has initiated an action that may result in a transition. The workflow decides whether to transition to another page, throw an error, or potentially another action.

Secondly is guidance around the naming of the events. In order to allow easy navigation changes to be made (one of the top reasons for using a Workflow plus visual designer I believe) and to still make sense in the code, the semantics of what is passed in should match the outgoing page, not the target. For example, if I click "Pay Bill" on a page, the event passed into the workflow should be "PayBill", not "DisplayShoppingBasket" (the name of the page that is transitioned to). Then, in the future if I add a confirmation page between the two, there is no semantic mismatch.

Two summary questions then; does anyone else have a view on this? And is there a plan to provide guidance around the naming etc of transitions and events?
Developer
Dec 20, 2006 at 12:54 PM
Hi, thanks for the feedback.

We completely agree with your point of view - the parameter supplied to the NavigateTo method should not be the name of the next view, because of the problems you mentioned.

That's why in our implementation we are using name "transitionName" for the parameter of the NavigateTo method instead of "viewName":

---
public interface IPageFlow
{
//...
void NavigateTo(string transitionName);
//...
}
---

This means that your application has to tell the PFAB which is the transition that the user wants to perform, and not the target view. This allows you to encapsulate navigation logic inside the page flow instance.
For example, in the Store Quickstart, the StoreController class has the following method:

---
public void CheckoutOrder()
{
StorePageFlow.NavigateTo("doCheckout");
}
---

The action to be performed is a checkout. Then, the page flow instance will decide whether to send the user to the checkout page (if everything is OK) or to an error page (if the user didn't have items in the cart).
You can see the page flow definition in the file StorePageFlow.cs.

Probably what it's confusing is the name of the method NavigateTo. What is the ideal name for you?

Thanks

Mariano Szklanny
http://staff.southworks.net/mariano
Dec 20, 2006 at 1:36 PM
Ah - with hindsight some of the calls I was looking at could have been named either way - "CustomerList" is the name of the next view, but aruably also the name of the action being performed. Excellent that we agree!!

Naming of the NavigateTo method is a tricky one - the examples I gave above were rubbish, I admit, mainly because nothing logical sprang to mind.

I think it could do with being something like "HandleUserAction", in that it implies the decision is for the flow to take - although does it actually need to be a user initiated action? Probably not, so this might be flawed.

Perhaps an alternative is to remove the "To" - i.e. rename it "Navigate". 99% of the time this is what is going to happen, but it removes the implication that you're stating the destination. Or perhaps "NavigateTransition".

I'd recommend a vote... so far I don't really like any of my own suggestions :-)

Some guidance around naming these should certainly go a long way to address the issue too. My main concern was around developers misunderstanding how best to use the functionality.
Dec 22, 2006 at 4:54 PM
In my opinion, IPageFlow State should be used by the controller instead of ASP.NET Session State.

Immediately, two advantages come out of this:

- No need to load a huge state if the user is running several simultaneous page flows.
- Just call IPageFlow.Next() and let the page flow decide where to in most of the cases.

IPageFlow.NavigateTo(string transitionName) would be just for imperative navigations like “CheckOut” and such. Nevertheless, it should be the page flow the entity responsible to check if the navigation is allowed and where to redirect if not.