createDocument() is the factory method and I can have another class MyAnotherDocument2 and then in the MyApplication class create an object of MyAnotherDocument2 and return it. This is the meaning of the defn : Factory Method (createDocument() here )defines an interface for creating an object, but let subclasses (MyApplication) decide which class to instantiate.
Please provide comments on my understanding. Thanks
The example looks pretty similar to the example they use in the Design Patterns book. I think your understanding of what is going on is correct. Remember that the alternate name for factory (and the name that I knew it by first) is virtual constructor. I'm not if what I wote is helpful or not. I'm sure you'll let me know. John
The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Joined: Mar 10, 2001
What you write here is always very much helpful. Thanks.