Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data Environment vs Hard Coding Open of Tables
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00087199
Message ID:
00087543
Views:
37
>I cannot find anywhere a discussion on the relative merits of :
>
>- Using the Data Environment to open all required files
>- Coding the Opening of files
>- Using Table Views.
>
>Any ideas, or any article one can refer me to ?

I think the subject of your message says it all..."Hard Coding". When you use VFP's default Data Environment object you are hard coding your data access. This means that if you ever upsize your application to client server it takes a tremendous amount of work to get there.

Views provide the first degree of separation between your application and the data source. This separation comes from the fact that you are referencing a view that in turn references a specific data source...whether it be local or remote.

However, there is yet another degree of separation that can be achieved by subclassing VFP's data environment. One of the greatest VFP3 Codebook legacies still found in our Codebook for Mere Mortals framework are Data Environment classes and Dynamic View Cursors.

The combination of these two classes allow you to refer to views generically...here's how:

Local views follow the naming convention of "lv_". Remote views follow the naming conventionof "rv_". For example, you can create a local view named "lv_Invoices" that references a local VFP invoices table. You can create a remote view named "rv_Invoices" that references a remote invoices table (SQL Server, Oracle, etc.).

Using Codebook data environments and dynamic view cursors, allows the application to refer generically to the invoices view as "v_Invoices". When the form instantiates, the framework loads the correct view based on whether the application is in "local" or "remote" data mode. If it's in local mode, the framework loads "lv_Invoices", ALIAS "v_Invoices". If it's in remote mode, the framework loads "rv_Invoices", ALIAS "v_Invoices".

This allows the application to refer generically to v_Invoices. So if you ever upsize to client-server, you don't need to change your application code. It will work "as is". In addition, your application can switch dynamically between local and remote data.

Hope this helps!
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Reply
Map
View

Click here to load this message in the networking platform