Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CApplication.AddChildren
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00389712
Message ID:
00392192
Views:
14
Mat,

<1. When you say create a factory method called CreateUserManager(), can you expain this further?>

A factory method is a method containing code that instantiates an object. In the Framework I use the naming convention 'Create(objectname)' to indicate a factory method. For example, the CAppBase class posseses methods such as CreateAbstractFactory(), CreateDBCMgr(), CreateGlobalEnvironment(), etc.

The nice thing about a factory method is that you can override it in a subclass. This gives you double the flexibility...in the Framework we're using a data driven Abstract Factory to instantiate main Framework components--the first level of flexibility. When we place the code that instantiates the object in a 'factory' method, you can completely override or extend that code--the second level of flexibility.

<2. If I call the factory method to create the UserMgr class, then what about the call in the parent AddChildren method? I currently have some code in my application AddChildren method, but I am also issuing a DODEFAULT(). Wouldn't the UsrMgr class still be created there?>

In my previous message I was suggesting a change to the Framework where this code wouuld be removed and replaced with a call to the new factory method. For example...

In CApplication.AddChildren():

Change...
This.Add('oUserMgr', This.oMMFactory.GetClassName('UserMgr'))

To...
This.CreateUserMgr()

In CAppBase (note this is one level up the food chain), add a new 'CreateUserMgr()' method that contains the following code:

This.Add('oUserMgr', This.oMMFactory.GetClassName('UserMgr'))

Would this buy you the flexibility you need?

Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform