Patterns would definitely be a good topic for a meeting.
----- Original Message ---- From: Cameron Childress <[EMAIL PROTECTED]> To: [email protected] Sent: Thursday, July 3, 2008 9:15:18 AM Subject: Re: [ACFUG Discuss] Destroy An Object On Thu, Jul 3, 2008 at 7:52 AM, Clarke Bishop <[EMAIL PROTECTED]> wrote: > But Cameron, you made me think of another question when you mentioned > calling init() on your user object. When do you create it? At the start of a > session? It depends on the site's requirements to scale. On an internal site like an intranet I sometimes will create a new user object in the onSessionStart() in the Application CFC. This allows me to init() the user and know (for example) that the session.user.firstname property will always be present. This tends to prevent alot of time development time spent worrying about isDefined() or structKeyExists() calls. For a public site that gets more traffic like search engines, which spawn new sessions with each request, I usually use a Session Facade to keep my user's session and only init the object and put it in session when a user logs in. If they are unauthenticated, the facade might still genrate a "Anonymous Visitor" user object on the fly, or give me one that's stored in the application scope. That's really part of the beauty of the Session Facade pattern. The facade gives me an object for that user's session, but it might or might not come from the actual session scope. All the complexity is masked inside the Session Facade and all I care about outside the Session Facade is "hey you there - give me a user object for the current request!", and it gives me one. My app doesn't care where it came from, just that it's there. Also, if anyone reading this is wondering, init() isn't some magic unknown thing in CF, it's just a method I always create (by convention) as a constructor in all my CFCs. I know that (according to my convention) that I should always call init() when I create an object instance, and that by calling that init() I know that all the properties inside the object will be set to their defaults. Would this stuff be a worthwhile topic for a meeting? Patterns? -Cameron -- Cameron Childress Sumo Consulting Inc http://www.sumoc.com --- cell: 678.637.5072 aim: cameroncf email: [EMAIL PROTECTED] ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com -------------------------------------------------------------
