Isolating Flow from Services
Posted by garysweaver on December 19, 2008 at 5:12 PM EST
As a follow-up from the previous article on the Interaction-Flow-Service-Model Architectural Pattern (IFSM), let's talk about suggestions for developing a more modular flow layer.
- All non-flow-related logic should be pushed to service layer (or an additional service-logic layer).
- Aim for simplicity in controllers and related contextual VOs. Unless something else is needed, lean towards using simple generic constructs such as a Map to store flow context.
- If persistance is required for any data (including flow-state) store and retrieve it via services and minimize and handling required in flow.
- Avoid use of complex flow logic, assumptions about flow control, and assumptions about scopes as they might be implementation-specific. The framework might offer 10 options for how to do something, but you choose the one that keeps things as simple as possible to guard against future changes.
- At times the services will need access to the original request object/external context. It is simple to wrap the request object/external context in another object that you can call to get specific information that you need from the request (like getting the remote user, getting a session param, checking a user's role, etc.), and it might save some headache later if you swap out the slow layer with another implementation that has a different concept of context.
- flowScope - within scope of a SWF2 "flow". Can be multiple flows per application. This is the primary scope used in SWF2. A smaller scope than web session, greater than scope of an web request.
- viewScope - scope within a SWF2 "view-state". A smaller scope than web session, greater than scope of an web request.
- requestScope - scope is from the point the flow is called until it returns. A smaller scope than web session, greater than scope of an web request.
- flashScope - variable only lives for a single render in a flow. Similar to the scope of a web request.
- conversationScope - is stored in web session, but is not equivalent to session. It only exists for as long as the top-level flow exists.
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- garysweaver's blog
- 1037 reads






Comments
by garysweaver - 2008-12-19 20:52
Just revised the post a bit. I'd left out flowScope in the original (argh- thanks Keith for noticing that- I'm so lame) and I think I royally screwed up that whole scope section because of that. Hopefully now it makes a little more sense.