Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stateful vs Stateless
Message
De
31/07/2000 18:02:11
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00399017
Message ID:
00399039
Vues:
15
>I am wrestling with the stateful vs stateless concept. Is the following code stateful?
>
>oCustomer.LoadData(lnPk) && get the latest customer data
>oCustomer.Data.Address = "123 Apple Street" && change customer data
>oCustomer.Data.ZipCode = 135827
>oCustomer.SaveData() && save the data (no validation checking)
>

Yes, this is stateful. Stateless would looklike:

oCustomer.Update(lnPk, "123 Apple Stree", "135827")


>To me the code seems stateful because line 4 is counting on the object to be still pointing to same record loaded in line 1 and assumed in lines 2 and 3.

You are correct.

>When will this code break?

If the object is cached by MTS or COM+, (like when using SetComplete or SetAbort) the actual object you get on the second call can (and probably will) be a different object.
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform