So I have an app I am building at work and we started it about 5 months ago. I put in about 3 weeks building a prototype of the UI and then got pulled onto another project. Now its time to revisit it and I found some design choices I am unsure about.

So this application has many views. One workflow is that as a user you login and you purchase a new product. Part of the process of making payment is that I have to send off to the server to have your credit card debited. So I create and instance of some CairngormEvent and attach my data. In turn the correct command gets launched and actually starts the call through my business delegate. Now in this case my delegate is (not?)important because its pretending to make the calls against a backend that doesn’t exist. Regardless the result is sent back to the result function of my command to be processed.

So here is what I propose. If the auth was a success then I think we should just send them to the next step from here. I can update a property in my ModelLocator and the viewstack will move along. But if the card failed, then I need to tell the user. I imagine that back when ViewHelpers were popular this would be an appropriate use. However now what is the best course of action?

I can tell you what I did. I have a CallBackEvent that extends my CairgnormEvent and I attach to it the function I would like called when the process is complete. This allows me to update my view without having to perform much witchcraft. And then my view can be responsible for its self in how it should proceed. I currently use the callback wether it was successful or not, and this morning i put the code to change my modelLocator in the callback function of the view. Thats the part I am not really liking. I feel like that should be put in the command, but what if I need to update the display locally if the auth is successful also(think loading screen)? So then would it be better to launch another event that says take me to the next page, and create a new command to handle that? Then the logic is maintained in my business layer, but its 2 more classes for 1 line of code. Which of course seems like overkill.

So how does that sound? Anybody for or against this method? I am still early enough that I can change if I am so swayed. So what would you do?

Technorati Tags: ,