Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data object
Message
De
18/01/2000 12:37:12
Bob Tracy
Independent Consultant
Driftwood, Texas, États-Unis
 
 
À
17/01/2000 22:37:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Divers
Thread ID:
00319280
Message ID:
00319512
Vues:
16
>I just got done reading Egger's "Advanced Object Oriented Programming with VFP 6.0". He has a chapter on Three-Tiered Development, and speaks in very broad generalizations about the Data Object, Business Object, and Interface Object, with no examples of any.
>
>Can anyone point me to some resource with details (like code examples)?
>
>TIA

David,

I had the exact same feeling coming away from Marcus' book. After much head-scratching and re-reading, I came up with the following as a data object. It's just a code snippet, I'll try to explain it as clearly as possible.

dfNewDataObject is a container class with only the AddProperty method set to public, everything else is hidden.
curTemp is created by a SQL Select that returns a data set.
Create a new array property (oRecord), the RecordCount property is optional.
Dimension the array the same size as the sql data set and add a record object to the array for each record in the data set.

You can pass the data object as a parameter, enumerate it like a collection, and treat it kinda like a simple-minded ADO recordset.

The snippet comes from a method named Retrieve in a class named datafactory in a class library called xVFPData. There is another classlibrary called xADOData that also has a method named Retrieve in a class called datafactory. The interface in both datafactory classes is identical (they are subclassed from an abstract class) and they both return the same data object. The point is that your middle-tier code never changes due to back-end platform, only the classlibrary you point to needs to change. The bad news: it takes overhead.

< snip >
oCollection = NEWOBJECT(dfNewDataObject,dfAbstractLib)
oCollection.AddProperty('oRecord[1,1]')
oCollection.AddProperty('RecordCount')
SELE curTemp
IF RECCOUNT() > 0
DIMENSION oCollection.oRecord[RECCOUNT()]
ELSE
DIMENSION oCollection.oRecord[1]
ENDIF
FOR n = 1 TO RECCOUNT()
SCATTER NAME oCollection.oRecord[n] MEMO
SKIP
NEXT n
oCollection.RecordCount = RECCOUNT()
USE
RETURN oCollection
< snip >

HTH.
Bob Tracy

Never engage in a battle of wits if you're only half armed.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform