On 10/29/07, Rich <[EMAIL PROTECTED]> wrote:
> I would suggest that you create a Session Facade and then have all your
> objects reference the façade.  It is generally a bad idea to have an object
> reference an external scope (session, request, etc.), and this technique
> hides the implementation from your business objects.

And having references to sessionFacade.getFoo() everywhere is somehow
better than having references to session.foo?

Having a giant kitchen sink session facade CFC is not a good idea and
is not encapsulation. That sort of session facade is not a coherent
object and having "sessionfacade" everywhere means you have not
encapsulated use of session scope at all - you've just required that
people call functions to get at data.

The better solution is to consider what data you have in session scope
in the first place and encapsulate each piece of data in an object
that relates to that data. You might have a user object in session
scope - encapsulate that knowledge in a userService (singleton). That
way you've encapsulated how the user is stored - none of your
application code knows about session scope (or sessionFacade!). You
ask the service to perform operations on the current user and it knows
how to do that. It can even give you the user object if you want to
operate on it directly. That means your application code is only
dependent on a fully encapsulated service. It also means that you can
change how the user object is stored independent of any other data in
session scope (because that other data is encapsulated elsewhere) and
nothing in your application needs to change.

Sorry, but this weird obsession with sessionFacade CFCs drives me nuts
- it's completely misguided and a very procedural way of thinking.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292273
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to