Hi Nando,

 

It didn't return an ID, the getCurrentUser() function *always* returns a
user object. However, how that is stored is encapsulated inside the function
so when I needed to stop storing the actual user object in session and just
store an ID the change was simple to make. Everything in the application
continued to receive a user object when they getCurrentUser() and so no
other changes were required.

 

---

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 Nando
Sent: 21 July 2009 12:34
To: [email protected]
Subject: [Model-Glue] Re: Accessing session scope

 

James,

I don't quite get how changing getCurrentUser() from returning an object to
returning an ID meant you only needed to make an internal change to your
user object, but OK. :-)

On Tue, Jul 21, 2009 at 12:45 PM, James Allen <[email protected]>
wrote:

That is a good point. So far I've only really tried the method I currently
use which is to encapsulate session access within the relevant service.

 

It has proven to be very useful though as when I needed to stop storing the
user object in session and change to only storing the ID the change was
quick to make and no other changes were needed in the entire application. I
like the fact that this is held within the service that it relates to - so
it's really easy to locate the functions at a later date.

I also use this method with cookie access. I have a function called
getCurrentStoredUser() and setCurrentStoredUser() which utilises the cookie
scope.

 

I can't see any real downsides in this approach to be honest, but as always
would be interested in hearing how other people handle it.

 

---

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 Nando
Sent: 21 July 2009 11:39


To: [email protected]
Subject: [Model-Glue] Re: Accessing session scope

 

Perhaps it might be useful to present the argument as to why encapsulation,
or which approach to encapsulation, is preferable, from your experience. I'm
still on the fence with this one and would be interested to hear what
benefits or drawbacks others have encountered. 

Nando

On Tue, Jul 21, 2009 at 12:34 PM, James Allen <[email protected]>
wrote:

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



 

 

 

 




-- 


Nando M. Breiter
The CarbonZero Project
CP 234
6934 Bioggio
Switzerland
+41 76 303 4477
[email protected]

 

 




-- 

Nando M. Breiter
The CarbonZero Project
CP 234
6934 Bioggio
Switzerland
+41 76 303 4477
[email protected]



--~--~---------~--~----~------------~-------~--~----~
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