>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