Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using cursoradapter
Message
From
08/08/2018 10:59:25
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
08/08/2018 09:11:29
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01661443
Message ID:
01661506
Views:
72
Likes (2)
>>>.cursorFill() is where set the select SQL command for later .cursorRefresh()
>>>
>>>Being able to change the cursor structure is a benefit of CAD over views
>>
>>One of advantages. Once I had the tamed CA, never looked back to other ways of handling remote data. Still use straight USE for local tables, or in my pet projects.
>
>I'm in need a way to begin programming in n-tier using CursorAdapter() or XMLAdapter(). What would it be the way to go?

The way we're doing it here is
1) have a general class of cursoradapters which does what you need, including automatic recognition of primary key and setting up those update lists, plus error handling in .before* and .after* events.
2) have a general bizobject class (with a couple of subclasses for categories of cases, eg. lookups or parametrized cursors pulled from the same table) with child bizobjects, so any .save(), .delete() etc methods would also call the same methods for all children's, cascading. One bizobject has one cursoradapter (though for some very simple cases it may have more, for side cursors where nothing much happens and the logic is simple).
3) do the GUI in the vcxes, have one main biz_object per form (custom, subclassed from one above, with children as needed) and then delegating any logic that needs to apply to bizobjects

It's not as much a matter of doing things strictly in this manner, but to adopt mentally this discipline of what goes where (which is the main question of OOP) - if it has anything to do with display and appearance, mentions .visible, dimensions etc, it belongs to vcx. If it is related to data crunching, pulling or saving - it belongs into a bizobject. As for the gory details of saving, buffering, SQL errors etc, that is the business of cursoradapter, and if done right, most of the time you don't even know that a CA exists, it just works in the background. You issue a tableupdate() in your bizobject (actually, .save(), and the tableupdate() is in the code of your base bizz class), and CA does its magic in the background.

Once you go through this, even refactoring old code is a good exercise, and when you're done, there's far less chaos in your code, and you know what's where. Far easier to debug.

Mind you, I did not write the classes I'm using - I only tested them and added or fixed a few things. If I had to do it myself, it would take me a month or two of doing nothing else. And it would still be worth the effort.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform