Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Superclass vs. Subclass structures
Message
 
To
28/10/1998 17:15:54
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00151975
Message ID:
00151983
Views:
22
One way to do it could use the bridge pattern, and instantiate the "mover engine" at the last minute.

PROCEDURE Init

DO CASE
CASE This.VehicleType = "PLANE"
This.oMover = CREATEOBJECT("PlaneMover")
CASE This.VehicleType = "CAR"
This.oMover = CREATEOBJECT("CarMover")
Etc.
Etc.

ENDPROC

PROCEDURE Move
This.oMover.Do()
ENDPROC

Init probably wouldn't be a good place for that, because it doesn't give This.VehicleType time to be set, but you get the idea. I have found it most useful to send an object handle "across the bridge" to facilitate two way communication. So it would be:

This.oMover = CREATEOBJECT("PlaneMover")
This.oMover.ParentHandle = This

Or, you could do it with parameters. I've been trying to avoid parameters lately.

Marty
Marty Smith, CSQE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform