Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Design Pattern - Factory and Abstract Factory
Message
From
03/10/2006 07:32:23
 
 
To
02/10/2006 17:26:12
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01082705
Message ID:
01158815
Views:
27
Hi, Mike.

>>>An abstract factory is a factory that returns one of a set of common concrete factories to produce one of a set of common concrete classes.
>>
>>Maybe you can take a look at my latest articles for UT Mag. I'm writing a column on Design Patterns in VFP. I already published the column about the Factory and the next one (I guess it is not released yet, but it should be coming out this week) is about the Abstract Factory. I'm not making data-driven factories for now, but if you rad the articles, I'd be glad to have some feedback from you.
>
>OK. Your factory method article is easy enough to follow. You have different kinds of factories, one for the user and one for the form. That's good.
>
>The thing is with all such articles, I want more!!!! Don't just demonstrate how the factory works, demonstrate how the factory is better than a simple CreateObject. For example, if you used a factory to instantiate all forms, you can make the entire app use a different form class by changing only one piece of code.

Of course, the idea of the column is to increase complexity over time, cmposing patterns to achieve higher results, but with the factories in my article you indeed have the chance to change all your forms instances to another class by just changing the factory implementation. Indeed, you can use a strategy there, or even a data-driven approach. Having the factory in place, and not a straight CreateObject makes it possible.

Granted, in VFP you can perform a CreateObject or NewObject with a string, so changing the string would be the same. It is just that having a variable or constant floating around is not as expressive as calling a method, in my opinion. Also, when I have more than one way to do something, and some of the apporaches are better ported to other languages/platforms, I prefer those, as make the code more understandable to outsider and the style more portable if needed.

>The data driven factory can do that too, but with no recompiling.
>
>In this article http://msvfp.advisorguide.com/doc/14038, I took an Iterator and a Visitor and did something substantial with them.

I'll take a look and surely include a link to your samples in my upcoming articles about these patterns.

Regards,
Previous
Reply
Map
View

Click here to load this message in the networking platform