Peter Bell wrote, On 12/21/2006 5:16 PM:
As for Q2, stick the data into a session variable. The biggest question is
what should stick the data into the session variable. The view doesn't as it
displays state - it doesn't change it (by recording within the session what
this person has viewed). Then ask whether if you were using Flex front end
you'd want this to still work. If so, it can't go in your (HTML specific)
controller, so put it in your model.


I like that you've thought about uses in different front ends. It's something I know I should consider, but don't do so as often as I should.


It IS OK for your model to be session aware as long as you distinguish the
different uses of session state (on my list of things to blog about) and
allow the appropriate uses to be handled by model and controller
respectively.

I think it could be OK. Well, I'm not sure that information is appropriate in a model, but I think it could be ok for a CFC to be session aware. In particular, I can see it would be inappropriate for a CFC to be relying on a session variable it doesn't create itself, or for code outside a CFC to rely on a session variable created within (a different) one, but for the case that it creates and uses it itself, I don't see any immediate drawback.

You MAY want to use a session façade as it will help if you ever change the
way you implement session state, but the debate as to whether to use scope
facades is still open - Doug Hughes posted about this some time back on his
blog. If you don't know what a session façade is, just stick this in the
model to start with and you can always refactor to a session façade down the
line. If you get the big architectural choices right upfront, tweaking the
smaller ones down the line is a good approach to avoid overthinking things.


You might also have some method setVarInStruct(var, struct), but I'm not sure what advantages or disadvantages that may provide. On the other hand, I don't immediately see what benefit using a facade may provide above the drawbacks I mentioned of using sessions in CFCs directly. I'm fairly sure there are some, so I wanted to ask you all. Well, I could see that it can handle the case a variable doesn't exist for you, so that is a nice thing... but what else?

-Sam



You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/cfcdev@cfczone.org

Reply via email to