Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Container Class VS Custom Class
Message
 
 
To
28/07/1999 19:06:55
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00243667
Message ID:
00247530
Views:
23
Tim,

I see you have Ed had a fruitful exchange today.

>I have experimented with this and although you can drop other objects onto a container I have not found how to control the order in which they are created/initialized. Am I missing something or should I not be designing my objects to depend upon a load order?

I generally avoid instantiation order dependency. To this end very little is typically done in Init() and some custom method that the Parent container can call for it's contained objects is used to "get them hooked together".

You can play with SendToBack to force the instantiation order, but this is quite fragile and just too much extra effort IMHO.

If you go the route of controlling the order by using AddObject() at runtime you force yourself into setting properties in a specific subclass, if you want to use the property sheet, or coding "long winded" property sets after your AddObject() call.

If I had a User class that had a couple of property values that need to be set specific for an app, I'd drop the class into the container, set the properties on the prop sheet and then put the sequence specific stuff in the parent.Init(). This also has the benefit that later on you come back to it and you can "see" the order dependence. If you have the order "hidden" by the instantiation order you make it harder for someone coming after you, or yourself 6 months from now, to know what's going on. Or you have to seed lots of defensive code into your classes where you make sure something else exists this kind of tight coupling makes a system more complex, increased complexity is bad.

You might start looking at design patterns to help you out too.

>For example I have created an application class and I have dropped eventlog, screen, environment, version, security and user instances onto it. These objects need to share information between each other that could be obtained when they are initialized if it were done in the right order otherwise I have to finish initializing the objects in the Init method of the application class by calling a seperate method in each child object (.User.setUser(),.Version.setVersion()).
>
>I this is the preferred method then I can live with it but I am tempted to define my application class in a .PRG so I can order them as I like. What is you approach?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform