Jamie Good points.
> 1. It assumes a 1-1 correspondence between the method and the implementing > class Yes, for sure. > 2. The if block actually documents the allowed values. In your approach I > have to go and read the getMethodCode() function to work out what class my > factory method is actually going to instantiate - but which class to > instantiate is precisely my factory method's responsibility, not anyone > else's. Right, the methodCode/contactType string is actually coming from the db and is used to create the object. That's what I was trying to get at above :). I do get your point that the explicit approach both documents and allows for any level of complexity of logical mapping between types/codes and objects. > 3. ... As opposed to the more cryptic "file not found" error your approach > would > produce. Furthermore, if there is some recovery to be done rather than just > throwing an exception, you'll have to check the methodCode against a list of > allowed values anyway. Yes, a check against a list or file existence is in order to provide a nicer error message. The if block approach seems good for handling type/object logical mappings during object creation, but I also had in mind another scenario - suppose you have a common set of files for each type: EmailContact.cfc, EmailContactValidator.cfc, emailContactForm.cfm PhoneContact.cfc, PhoneContactValidator.cfc, phoneContactForm.cfm SMSContact.cfc, SMSContactValidator.cfc, smsContactForm.cfm At the moment I can only think of using the naming convention approach to prevent duplicating the if block where each of the files is used. Any suggestions in this case? Kevan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
