Posted by Michael G on 11/15/56 11:22
I want to use a factory pattern to create a variety of objects. Which object
gets created depends on a string that is passed to the factory create
method. I would like to avoid using an if or switch construct to accomplish
this but not sure how. For example,
....
if($nextObject == "login")
{
return new Login();
}
else if($nextObject == "validatedata")
{
return new Validate(aString);
}
....
Is there any way to avoid this?
Thanks, Mike
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
[Back to original message]
|