Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Superclass vs. Subclass structures
Message
 
À
28/10/1998 17:15:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00151975
Message ID:
00151983
Vues:
20
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform