Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stateless Objects.
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00416469
Message ID:
00416632
Views:
24
Not sure. I guess one could have

.Save(MyADOCursor)

This call could validate the data, save it then pass back an object detailing whether or not the validation was okay and which rules were broken. This could save the round trips through the tiers. But this is just thinking off the cuff.

Good point about a biz rule changing between .Validate() and .Save()
>I was thinking about the .validate / .save question you asked last night at the chat. I don't think you would want to do what you mentioned. It would result in round-tripping data to the server.
>
>I've haven't done this but I think this is how it works. Perhaps someone with more experience can jump in and help out. :)
>
>Example:
>
>The physical representation would be:
>
ClientMachine-----AppServer------DBServer
>      |               |              |
>   Form for        Customer       Customer
>   Data Entry      BisObject        Data
>
>A component resides on AppServer named Customer
>The Customer component has 3 methods
>
>.Validate(ADOcursor)
>Parameter is a cursor with all the customer data,
>it returns a boolean specifing if the data is valid (.T.) or invalid (.F.)
>
>.Save(ADOcursor)
>Parameter is a cursor with all the customer data.
>
>.GetBrokenRules(ADOcursor)
>Parameter is a cursor with all the customer data,
>it returns an ADO cursor that contians 1 row for each broken rule.
>
>A client application on ClientMachine shows a form that allows a user to enter data for a new customer.
>
>The user clicks save, the UI save code does the following:
>
>
>** First populate an ADO cursor (rstCustomer)with all the customer data
>
>** Do the save.
>if oCustomer.Validate(rstCustomer)  && Send data to AppServer (First Trip)
>    this.BrokenRules = .F.
>    oCustomer.Save(rstCustomer)  && Send Data to AppServer (Second Trip)
>else
>    this.BrokenRules = .T.
>    rstBrokenRules = oCustomer.GetBrokenRules(rstCustomer)  && SendData to AppServer (Second Trip)
>endif
>
>if this.BrokenRules
>    ** Loop through rstBrokenRules and notify the user of
>       each broken rule
>    return .f.
>else
>    return .t.
>endif
>
>
>
>Another problem would be a business rule could become broken between the time .Validate() and .Save() are called. For example a bis rule states "All Customer Names shall be unique." You may call .Validate() and your name is unique, another user saves a customer with the same name, then you save. A bis rule is now broked. And the opposite could happen as well, You validate, a bis rule is broken, and could be unbroken (a customer is deleted by someone else) before you can .GetBrokenRules()
>
>Better, I think would be a single .Save method that returns the BrokenRules cursor.
>
>rstBrokenRules = oCustomer.Save(rstCustomer) && Send data to AppServer (First Trip)
>
>
if rstBrokenRules.count > 0
>    ** Loop through rstBrokenRules and notify the user of
>    **   each broken rule
>endif
>
>At least that's how I think it works.
>
Previous
Reply
Map
View

Click here to load this message in the networking platform