tag:blogger.com,1999:blog-13751027.post115777614019172505..comments2024-01-10T19:56:04.278-08:00Comments on What do you want to program today?: Simple factory pattern made simplerBlackTigerXhttp://www.blogger.com/profile/05376454374607771065noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-13751027.post-1157825127568972682006-09-09T11:05:00.000-07:002006-09-09T11:05:00.000-07:00This particular implementation is for a simple pat...This particular implementation is for a simple pattern factory, and if you wanted to add a product to the factory, you would have to modify the factory anyway regardless of how you implement it<BR/><BR/>it is a very specific case where you can use this particular example, but works really well<BR/><BR/>in this example yes, I'm passing the type my self, but that could come from a configuration file, a web service call, etcBlackTigerXhttps://www.blogger.com/profile/05376454374607771065noreply@blogger.comtag:blogger.com,1999:blog-13751027.post-1157803190962691042006-09-09T04:59:00.000-07:002006-09-09T04:59:00.000-07:00Hi,maybe it's because I'm a Java programmer, but t...Hi,<BR/><BR/>maybe it's because I'm a Java programmer, but that implementation of a Factory is not good (politely speaking). Don't you have a Class.newInstance() equivalent?<BR/><BR/>The main problem is that if you want to add a new type of Enum, you have to add a new index to the array, so you modify the factory for each new type.<BR/><BR/>That, and the fact that calling the factory with the type you want to create is kinda the same as creating it yourself. I think the whole idea of the factory pattern is the client class not knowing wich concrete class is being created.<BR/><BR/>Well, just my thought.. again, maybe it's a good implementation in C#, but it does have some conceptual errors anyway.<BR/><BR/>Regards,<BR/>Pablo.Anonymousnoreply@blogger.com