The way you described is a common approach (although you should move that productManager creation code into a separate function in productFactory - IMHO and beside the point). You are correct in thinking that would (or could) be a lot of subclassing. Other GoF patterns to look at for inspiration might be Mediator (to encapsulate complex object relationships), or Builder (to encapsulate complex object creation). Often behavioral patterns (like Mediator) can be combined with creational patterns (Builder and Factory), so you can achieve what you are looking for with some configuration of these...
Either way though, they all involve quite a bit of subclassing/writing new code as requirements are added or changed, and aren't exactly as flexible as you might like for requirements that are likely to be "fluid" (ie, new configs on the fly). To get around that, you could use XML to store the configuration for each user role, wiring together different objects as needed. Personally, I think XML can at times be an excellent alternative to subclassing, and works well in cases like this. HTH, Scott Keene [EMAIL PROTECTED] ----------------------------------- CFOOP :: Object Oriented ColdFusion http://www.cfoop.com > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Suyer, Ed > Sent: Monday, March 01, 2004 5:06 PM > To: '[EMAIL PROTECTED]' > Subject: [CFCDev] Looking for design pattern advice: role > based permission to objec ts > > Hi Experts: > > Would appreciate if you could share your advice: how to keep > the customization info of a web application. > > some sample requirements: > > 1. menu is dynamically created based on the Role of the logon user > > 2. Tables can be customized - for example, which columns to > display, editable, sortable, etc. > > So in an OO application, where should I keep these > customization information? What design pattern / set of > patterns do you recommend? > > My initial thought was to create a factory that created a > different manager based on role > > i.e > main.cfm: > productManager = createobject('component', > 'productFactory').init(session.user.role); > > productFactory.cfc: > function init (role) { > var productManager = createobject('component', > 'productManager'&role).init(); > return productManager; > } > > > With this approach, I will need a seperate productManager for > every role. > And every productManager would define only the properties and > methods available to that role. So it would work ... but > then I would need a CFC for every object-role combination. > It strikes me that there must be a better way? How have > otheres implemented role-based permissions in there OO apps? > > Any help is much appreciated! > > Ed. > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported by > Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
