Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stateful vs Stateless
Message
From
31/07/2000 18:02:11
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00399017
Message ID:
00399039
Views:
13
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform