1 person found this helpful
Firstly, you say your canAccess method has 2 optional arguments for the userID and pageID. This doesn't really make sense, those arguments should both be mandatory, as the function won't work without them, right? I'm guessing you're doing something like:
<cfargument name="userID" required="false" default="#session.userID#">
<cfargument name="pageID" required="false" default="#request.pageID#">
If so, this isn't good OOP because you want to decouple your CFC from referencing any shared scopes. This is a good article about the basic principles involved:
Instead your code should be make those arguments required without defaults.
Secondly, I don't see any problem with the basic idea of defaulting to the session ID or the page ID, however I'd move that logic out of your CFC (if that is how you're doing it), and into however you call that function.
An interesting concept of OOP; I had never heard of decoupling, but after hearing your explanation, that makes sense. Rather than the "benefit" of being able to optionally provide an argument, and have it default to something, it should instead, always rely on data that is passed into it. Excellent point!
Thanks for the article link!
This OOP stuff is a really great methodology.