Wednesday, January 16, 2008

Oops foundation centralized coding in Visual DataFlex

OOPS Foundation Centralized Coding in Visual DataFlex:

One of the most fundamental concepts in oops programming [object oriented] is centralized coding so that unlike previous spaghetti code where the same calculation was formulated over and over again in different code segments, instead we now place the code in one spot so that if business rules change then we go to one spot, change the code, and we're done.

Earlier attempts at centralized coding involved gosubs where the same piece of code was reused, but with Visual DataFlex, utilizing datadictionaries, we have hooks in the finding process and constrain process for instance where the code is placed in a "stored procedure" along with all the other rules of the datadictionary class for a table. In Visual DataFlex methodology, which supports full message delegation, the find passes through a DDO [data dictionary object] which delegates the find to it's DD class code and utilizes the onconstrain method of the class as well as the object.

Technique: in order to fully utilize delegation, we "forward send" each message even if it is an "event" method.

The code described below takes a business rule exception to constrain a table by it's status which is used throughout a system in many places including windows data entry, batch processing, and webapp interfaces.

The beauty of Visual DataFlex database centric code is that this one event can be turned on or off by a property setting [business rule exception] in any of the above mentioned applications.

Here's some sample code:


This is intended as a "get-to-know features of Visual DataFlex" article.
Sincerely,
Peter Donovan

No comments: