Loading ...
Sorry, an error occurred while loading the content.

Comments on XML Schema, Persistent objects, & more

Expand Messages
  • adnd-pcgen@eec.com
    Well, this has been an interesting discussion so far. :-) I have a couple of things that I d like to point out, although they don t affect Keith s XML design
    Message 1 of 1 , Oct 7, 2002
      Well, this has been an interesting discussion so far. :-)

      I have a couple of things that I'd like to point out, although they don't
      affect Keith's XML design in the least (I think).

      I'd like the Java objects that are created during the parsing process to
      be saved as persistent objects to an external data stream. At the next
      execution of PCGen, check the modification time on the original source
      (spells_level1.xml, or whatever) and compare it to the modification
      time on the serialized object file (spells_level1.job -- I chose "job"
      for Java OBject). This will significantly speed up the load process
      on subsequent executions of the program. There will be one caveat,
      however, that I don't see a simple fix for (obvious, but not simple):
      if the spells_level1.xml has an include for another XML file, how would
      that be represented? I mean, if the mtime of either spells_level1.xml
      or included_file.xml were more recent, we would need to reparse the
      spells_level1.xml file. But where do we store that information?
      It almost sounds like we need another list (built in memory at parse
      time) that describes the dependency graph of the loaded XML files.
      That graph would need to be written as well (serialized as an object,
      just like the other Java objects) and read in as the first step in
      loading the data files. It would tell us which source files to check
      in determining whether the XML needed to be reparsed. (Can anyone say
      "make"? I knew you could. :-)

      Concerning Keith's comment about XML Schema and validating input, I don't
      see why we can't use it to determine that numeric fields contain numbers
      and that they are in the correct range; the current schema standard
      provides for declaring the type of attributes, as well as minimum and
      maximum values, for instance. It means less error-checking in the
      application. And besides, if the technique above is adopted, it is only
      used when the XML changes, so the performance hit taken by using XML
      Schema only happens once at install time (as part of the install process!)
      and then again only when the data changes. :-)

      I haven't seen it specifically mentioned, although it has been implied a
      number of times. So I'm going to just say it out loud: The back-end data
      engine will be chosen using (static) factory methods of a base class. For
      example, the programmer calls BaseClass.getInstance() and the first call
      to getInstance() triggers a look-up in a configuration file to determine
      which database engine to use. The return value from the factory method is
      an object reference to the correct class, although it is treated as a
      reference to BaseClass by the application. And the getInstance() method
      uses Class.forName("...") to load the class and similar stuff to create
      the object.

      I have some IMHO's re: MVC, but they are not germane to the task of
      building an XML design, so I won't bring them up in this forum. :-)

      Another poster made a comment about using base classes and abstract
      classes, then inheriting from them, as an alternative to C++'s templates.
      If you haven't worked in C++ a long time, you may not understand why
      inheritance is not good enough. It has to do with two key features of
      templates: code maintenance (there is ever only one implementation per
      *concept*, not per data type), and flexibility (if a data type change
      *does* force a change to the implementation of the concept, it can be
      easily accomodated).

      I teach both C++ and Java programming (and OOA&D as well) and students
      sometimes have a hard time with those two until they see some practical
      examples of each. Way too much effort to go into here, though...

      If inheritance were good enough, IBM wouldn't be working on their Java
      front-end which will provide templates for Java. (It's called GenJ or
      something like that. It will be a preprocessor for Java, sort of like C's
      preprocessor, that spits out regular Java code. But that Java code will
      be typesafe. They plan to add full and partial specialization to their
      templates, so there won't be any reason not to use them in Java. :-)

      I just wish I had some time so I could help out on this! I am so jazzed
      by reading the comments here and thinking about the possibilities, but
      business just takes up too much of my time lately (sigh).

      Frank J. Edwards Edwards & Edwards Consulting
      Voice: (813)991-0366 http://www.eec.com/Dnd/
      Fax: (813)991-6074 Send "help" to <adnd-request@...> for info
      Email: adnd@... (you must send it from your subscription address)
    Your message has been successfully submitted and would be delivered to recipients shortly.