Aha, yes the classic session facade vs direct access via the model debate. J

 

I access the scope directly but only from those two functions. I prefer this
idea instead of using a facade as it's just as easy to go into my two
accessor functions and change how the data is accessed as required. It's
also nicely contextual as it's handled by my userService - so everything is
in one place. As long as it's encapsulated it's ok with me..

 

---

James Allen

E: [email protected]

Blog: http://jamesallen.name

Twitter: @CFJamesAllen (Coldfusion / Web development)

Twitter: @jamesallenuk (General)

 

From: [email protected] [mailto:[email protected]] On
Behalf Of Chris Blackwell
Sent: 21 July 2009 11:30
To: [email protected]
Subject: [Model-Glue] Re: Accessing session scope

 

but are those two methods in your userService directly accessing the session
scope or are you using a facade?

 

[can of worms] *pop*

 

2009/7/21 James Allen <[email protected]>


Hey there Gavin,

What I do with accessing these kind of scopes is I encapsulate the access
within my model. The best example of this is when accessing the current user
which is stored in session. Within my UserService I have two methods:
getCurrentUser() and setCurrentUser(). These two methods are the *only*
place where the session scope is accessed relating to the user object. I
like this method as it means that if I ever move from session to client I
can make the change in those methods and the entire application will
continue to run as it should without any other changes needed. It was also
really cool when I needed to change from storing the user object itself in
session to only storing the ID. Once again I only had to make the change in
one place.

So basically I recommend encapsulating scope access as much as possible
inside the model.

Cheers,
James.

---
James Allen
E: [email protected]
Blog: http://jamesallen.name
Twitter: @CFJamesAllen (Coldfusion / Web development)
Twitter: @jamesallenuk (General)


-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Gavin Stewart
Sent: 21 July 2009 09:46
To: model-glue
Subject: [Model-Glue] Accessing session scope


Hello there,

I am a newby to model glue and was just wondering if is best practise
to access the session scope in controller.cfc or is there a way to
pass it in?

Cheers,
Gavin





 




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to