Setting up gnucash to use postgesql back end - close but no cigar ...

Jan Steinman Jan at EcoReality.org
Wed Mar 11 16:10:21 EDT 2015


> From: John Ralls <jralls at ceridwen.us>

> Most object-oriented patterns originated in SmallTalk. [sic] The standard intermediate reference is Gamma et al., "Design Patterns", often referred to as "Gang of Four" or "GoF". It's also the parent of all software design books named "Patterns...".

Ralph Johnson was my first consulting client. I had implemented Smalltalk for the Tektronix workstations he was using at Rutgers. Doing massively parallel computational fluid dynamics in Smalltalk was a gas! On a 16 MHz 68020 processor! We worked for weeks, improving the model, finally subclassing Process, which was a bit hairy, since the inner guts of Smalltalk makes a lot of assumptions about Process instances.

Actually, the originator of applying patterns to software was Ward Cunningham, who was also the inventor of the wiki concept. I worked with him in Tektronix Computer Research Labs in the 80s. Ward's original application of software patterns is based on the work of architect Christopher Alexander ("A Pattern Language")., which should rightfully be considered "the parent of all software design books named "Patterns..."." Ward's "Portland Pattern Repository" is still available at the world's oldest continuously running wiki: http://www.c2.com/cgi/wiki?WelcomeVisitors . (Warning: don't expect "eye candy." Average page load is probably only 15kb. This is quite zippy on what is rumoured to be a '386 box, written in Perl.)

> Enough CS history, and enough theory.

Aw, we were just getting started! But beware of assuming history is only what is in books. Ward didn't publish much, but forgot more good ideas than most people ever have. He influenced dozens of people who later went on to put Ward's ideas to paper. Look for him in the "Acknowledgements" sections of your favourite software design books.

> The expression of the model is in GnuCash code, and there it is likely to stay.

Bummer. Okay. I'll quit grousing now.

> That's the direction I'm leading us. Where would you go?

Sigh. Long story. Having written accounting software for NASDAQ, derivatives management for Morgan Stanley, and mutual funds management for JP Morgan, I would probably excessively complexify it. :-(

But primarily, I'd start with a fifth-normal-form data model (a la Date and Codd) -- at least on paper -- that could be driven independently of the GUI. And then kick myself in the butt at every thought of making it more complex or of pre-optimizing it.

> You never answered the question about what you mean by "interoperable".

Two levels:

1) Easy and simple read-only data model access. It seems to me that would mean exploding the slots table and normalizing it. I confess I haven't spent much time deciphering it, but it appears to have self-join information that should probably be factored out into multiple tables. It would be good to use DECIMAL types, instead of implementing your own arbitrary precision math. (Been there, done that.) But XML doesn't have that, so it seems maintaining XML is a bit of a hobble in moving to a relational model.

2) Then when it's in (at least) fourth normal form, make foreign key constraints so you could do record-level locking and have reasonable transaction granularity. (Do Postgress and SQLite have triggers? Easier and faster than transactions.)

I think you have the data model backwards: you're deriving relational data from your XML model, no? I'd do a pure relational design, then import/export XML from that, if necessary.

Right now, it appears that referential integrity is maintained by the GNUCash code, rather than the database. This means you cannot have record locking, and cannot make it multi-user without database-level locking. (Or at least, locking multiple tables.) It also means you're needlessly re-implementing a lot of stuff that a database gives you for free.

You have done a lot of great work, which I don't mean to deprecate in any way. I'm not really in any position to commit large amounts of time to this, so as I said, I'll quit grousing now. Carry on with the good work!

----------------
:::: Jan Steinman, {link:"http://www.EcoReality.org" textDesc:"EcoReality Co-op" :link} ::::



More information about the gnucash-user mailing list