Search the web
Sign In
New User? Sign Up
fusebox5
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Session Objects   Message List  
Reply | Forward Message #2381 of 4405 |
Re: [fusebox5] Re: Session Objects

It helps with testing because you can write the session facade in such a way that it will accept a scope as an argument (ie setSessionScope()). I just default this to the real session scope so that is what the real application will use. But it means if I write a unit test, I can pass in a structure to the facade and it will use that in place of the session scope. That way I can run tests against the CFC without having to set up some sort of dummy <cfapplication> with the session scope turned on just to let the test run. The same goes for any other components where you were going to use the session scope prior to adding a session facade. They don't need to know anything about the session scope either, all they care about is that they have a session facade object they can use. So during testing, it's easy to supply the CFC with a mock session facade that just mimics what the real session facade CFC would do, without using the session scope.

As is virtually always the case, encapsulating something makes it easier to test. Likewise, how easy it is to test something is a good indicator of the quality of the design. If you have to create an application scope, session scope, or lots of other components just to test one thing, it means you probably need to refactor to reduce the dependencies. Components should know as little about the rest of the system or the context of their use as possible.

I don't have any articles on session facades specifically, but the underlying idea (encapsulation) is the same for any object. Any book or article on good OO design would apply.

Hope that helps.

----- Original Message ----
From: ultra_blue <greg@...>
To: fusebox5@yahoogroups.com
Sent: Thursday, August 2, 2007 1:05:49 PM
Subject: [fusebox5] Re: Session Objects

Brian:

Thanks for the reply. I actually had a session facade manager class
written for this, but I wasn't sure what it was doing there. It's been
a while since I've been working on this code. It looks like it's
working -- I've been able to eliminate the need for session scoped
objects in my code, which is what I was really after.

So, no, I don't need to do double-checked locking since FB handles
application scope locking, and the session facade class handles
session locking.

I am a little unclear as to why this helps with testing, though?

Also, could you post links to some of your articles about session facades?

Thanks!
Blue

--- In fusebox5@yahoogroup s.com, Brian Kotek <brian428@.. .> wrote:
>
> Well first ask yourself if you really need to do double-checked
locking here. It probably can't hurt but it is also probably overkill.
>
> What you describe will work. Personally, I don't like referencing
things in the session scope directly all over my code. I create an
application- scoped Session Facade component and all requests that get
or set things into the session scope go through this singleton
component. That way knowledge about the fact that the session scope is
being used is encapsulated in only one place, in the Session Facade.
It's my personal preference since it helps limit the impact of future
changes and also makes things easier to unit test (I don't have to
actually enable the session scope for my tests to run).

(My original message snipped.)




Thu Aug 2, 2007 7:44 pm

brian428
Offline Offline
Send Email Send Email

Forward
Message #2381 of 4405 |
Expand Messages Author Sort by Date

Hello: First, sorry if this has been addressed elsewhere. If it has, please point me the posting. I'm using the following pattern to create session objects...
ultra_blue
Online Now Send Email
Aug 1, 2007
5:17 pm

Although my answer isn't related to your original question, but I would use a scope lock instead of named for session variables. HTH Qasim ... -- Qasim Rasheed...
Qasim Rasheed
qasim_1976
Offline Send Email
Aug 1, 2007
5:57 pm

Qasim: Thanks for your reply -- I was able to get on track with Brian's response, and eliminate the need for scope locking in the FB code altogether. Blue ... ...
ultra_blue
Online Now Send Email
Aug 2, 2007
5:08 pm

Well first ask yourself if you really need to do double-checked locking here. It probably can't hurt but it is also probably overkill. What you describe will...
Brian Kotek
brian428
Offline Send Email
Aug 1, 2007
6:06 pm

Brian: Thanks for the reply. I actually had a session facade manager class written for this, but I wasn't sure what it was doing there. It's been a while since...
ultra_blue
Online Now Send Email
Aug 2, 2007
5:07 pm

It helps with testing because you can write the session facade in such a way that it will accept a scope as an argument (ie setSessionScope()). I just default...
Brian Kotek
brian428
Offline Send Email
Aug 2, 2007
7:46 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help