define class myCustDataEntity as session *enforces private session upon object instantiation *all other forms used use default datasession and act as limitation free form set basically cDataEntryForm='.\myDataForm.scx' cSearchForn='.\myGridSearchForm.scx' cLookupForm'.\myLookupForm.scx' *Object reference properties to all the forms this data entity object is calling *so this object have object handle to all forms it is calling oSearchGridForm=.f. oEditForm=.f. oLookupForm = .f. oCustomerInvoicesForm=.f. *forms themselves keep object reference to underlying this data entity object as well. &&init of every instantiated form gets ref to this object as parameter and store it for further use. procedure init set date british set multilocks on . . *etc. this.OpenTables() procedure OpenTables use customers in 0 shared ... use invoices in 0 shared ... etc. procedure ShowCustomers **can be grid search form ** store object ref to property oSearchForn ** store this object ref to a custom property on that form, so form can call methods 'underneath' procedure EditCustomer &&called from the search form itself via object ref lparameter nCustId *find it in database *show edit form *user make changes *press save or cancell *we return that choice return lSaveChanges procedure LookupCustomer **show lookup search form return nCustId procedure ShowCustomerInvoices **show all invoices *select statement.. *report or such procedure SaveAllChanges **save buffered changes to underlying tables ** (oversimplified meta code) begin tran err=tableupdate1 err=tableupdate2 if !err end tran else rollback endif procedure RevertAllChanges tablerevert1 tablerevert2 tablerevert3 enddefineThis little 'entity framework' enables us to;
local oCustomer oCustomer=createobject('myCustDataEntity') oCustomer.ShowCustomers() &&Search grid or other search form *or oCustomer.ShowCustomerInvoices() && form or report *or whatever else customer related you made thereonce you release object.. puffff!!
define class myOldDosCustomers procedure Init procedure OpenTables procedure ShowCustomers &&form becomes new 'wait state' instead of menu to.. ** but then all the calculations we want to keep can be copied and become functional here as methods of the class dosproc5 &&heavy calculations on customer data dosproc6 &&heavy calculations 2 dosproc7 &&heavy calculations 3 enddefine <pre> And voila! Our old structural code becomes cool 'entity objects' :-)) <pre> local oCustomer oCustomer=createobejct('myOldDosCustomers') call that heavy processing procedure within new environment oCustomer.dosproc5 &&heavy calculations on customer dataand again you release object and poufff... all gone and clean.