-
1. Re: OOP - The scale of method functionality.
duncancumming Oct 15, 2013 1:20 AM (in response to Aegis Kleais)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.
-
2. Re: OOP - The scale of method functionality.
Aegis Kleais Oct 15, 2013 11:54 AM (in response to duncancumming)Thanks Duncan!
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.

