• Object serialization - how to?

    From Szyk Cech@21:1/5 to All on Sun Jul 28 11:33:08 2019
    XPost: comp.object.databases, alt.comp.databases, alt.comp.apps.databases


    I want to write my education database app. But before I start it I want
    to write decent database serialization and update system. This system
    will allow me to follow good advice: DRY (don't repeat yourself). In
    this case I don't want reimplement my objects definitions one in C++ and
    two in SQL. In order to do this I will extend a bit C++ class
    declarations with dumb defines: PRIMARY_KEY,
    FOREIGN_KEY(class.variable1, class.variableN), INDEX, NO_STORE). This
    defines have only matter for my class definitions parser. This parser is
    input for SQL structure generator and for SQL upgrade patches. The only
    not automated matter is migrateData() function (it is generated broken
    in order to avoid destroy database by mistake).

    This allow me to fully automatic database structure tracking with
    automatic patches.

    In true I did this already.

    I have class hierarchy like this:
    Where every DatabaseX has update() and migrate() functions.

    Then I have some thing like this:
    using Db = DatabaseN;
    class DbMyApp : public Db
    // Specific app db/SQL calls here (covered by C++ functions)

    This allow me to use lastly generated database in my app (without any
    global renaming or something like this) - this allow minimize needed
    changes in the code.

    So I have one huge DatabaseN class aka Db and it serialize and
    unserialize all storable classes in my app.

    But in my new work I see some thing different than my approach. They
    implement serialization abstract class and then for every storable class
    they implement separate serialization class.

    My question is that:
    What approach is better? And why? One global serialization class or
    maybe one serialization class for each storable class?

    I thing that my implementation is better, because I have care only for
    one, huge Database class, I have no problems with renaming many of them,
    I don't have remember how my serialization classes are named, many
    includes are not needed. So it is handy in one big generated class.

    What is bad: test Database class generator and Sql patches generator is
    kind of night mare in both approach. Because you have to write program
    which test program which generate programs. But I proudly did it once.
    But I want it make better next time (in Qt independent way, because in
    the future I want to drop this lib entirely).

    Thanks in advance and
    best regards
    Szyk Cech

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)