Saturday, July 28, 2012

One advantage of Logic in the DB: PHP classes for LedgerSMB coming soon!

The perpetual argument over logic in the db will continue forever, but here's one advantage that is often overlooked:  stored procedures provide a powerful way to integrate programs written in different environments.

Case in point:  Yesterday when I got tired of staring at Perl code, I wrote some basic PHP classes to provide integration logic for LedgerSMB.  The basic interface which performs query mapping functions, took me a couple of hours including debugging, despite the fact that I haven't programmed in PHP since 4.2 was current, and includes an additional class for retrieving/saving company records as well.  Not everything works yet but this will probably be finished up today.

These classes will make writing integration logic with portions of the software which have been moved over to stored procedures quite easy, and such code that calls stored procedures will be provably free of SQL injection and privilege escalation.

I haven't decided where to put this, whether in the main LedgerSMB project or in another Sourceforge project but it is coming soon.  Once these are working I intend to teach myself enough Java to write the same in that language,

Long-run there is a lot of boilerplate code that will probably be able to be generated by code generators in all these languages.  The code generators will eventually have to query system catalogs, and some custom application catalogs.  This will minimize the amount of code that will have to be written by hand.

No comments:

Post a Comment