Ben, your post is more that I was getting at...
Really, though, like Hal said in another post to this thread, Simon Horwith said at PbD, and others have said... if you want Java, program in Java. It's not what CF was meant for.
Incidentally, though, Ben... if you had 2 objects both called user.cfc, one at /lib/classes/null/user.cfc and one at /lib/classes/user.cfc and the init method for either simply returned "user" they should be interchangeable so long as they both implemented isUserAuthenticated() with the same returntype.
Granted, some folks are wanting to have the fully-qualified type signature, which wouldn't work that way. But, it could be done using simple types.
Laterz!
J
On 5/12/05, Ben Rogers <[EMAIL PROTECTED]> wrote:
There is a pattern called "Null Object", if I remember correctly. I use it
quite a bit, especially in regards to security. The component can either be
the same component that you usually return or a completely separate
component which implements the same interface.
For instance, if you're building a security system, you don't want to do
this everywhere:
<cfif isUserAuthenticated() and Session.User.IsUserInGroup (Group)>
...
</cfif>
It's much cleaner to use the Null Object pattern and have a User component
that always returns "false" when IsUserInGroup() is called. When the user
logs in, the Null Object is either replaced with a fully initialized object
that knows what to answer when IsUserInGroup() is called. Or, the User
component could double as the Null Object itself and the default answer to
IsUserInGroup() is always "false". Either way, your code looks like this:
<cfif Session.User.IsUserInGroup(Group)>
...
</cfif>
However, if you have to use two separate components, then they will have
different names and, as a result, the returntype attribute will need to be
set to "any". So, it doesn't solve much in the way of type checking.
Ben Rogers
http://www.c4.net
v.508.240.0051
f.508.240.0057
--
---------------
-------------------------------------
Buy SQLSurveyor!
http://www.web-relevant.com/sqlsurveyor
Never make your developers open Enterprise Manager again. ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
