[Tutor] preliminary app design question

Alan Gauld alan.gauld at freenet.co.uk
Wed Apr 5 20:44:19 CEST 2006


> wxPython, but nothing very complex. I want to write a suite of in-house
> structural engineering design programs for my own purposes.

Sounds emminently pythonic.

> - write each program independently as a standalone structural design app
> - design and write the programs in such a way that in the future I can
> create a project app that would link all these smaller apps together

Sounds like creating each app as a class which can be instantiated on
demand by the master application would be a possible design option.

> - I want the input/output of each program to be easily adaptable and
> readable by the 'project app' in the future
> - I would want the individual programs to have file formats that are 
> easily
> extensible as I add features to them

Almost a definition of what XML is good for. A data format that can
be changed without breaking legacy code.

> - The 'project app' would have to be extensible in that I could link
> smaller apps to it as I create them and it should be able to handle
> revisions to these smaller apps as I make them.

The class approach coupled to a config XML file would do this.
Define a file that looks something like

<applications>
    <application>
        <displayName>My Foo App</displayName>
        <className>Foo</className>
        </icon src="myfoo.gif">
        <params>
             <param>
                   <name>MyName</name>
                    </value default="15">
             </param>
             <param>
                   <name>AnotherName</name>
                    </value default="0">
             </param>
       </params>
   </application>
    <application>
        <displayName>My Bar App</displayName>
        <className>Bar</className>
        </icon src="mybar.gif">
        <params>
             <param>
                   <name>SomeName</name>
                    </value default="None">
             </param>
       </params>
   </application>
</applications>

Then you can read that and use it to construct a menu or set of buttons
or toolbar or whatever.

> Obviously this won't happen right away, I would likely develop each
> small design app as a standalone and then when I've got 3 or 4 done
> I would tie them together with the project app.

Why wait for 3 or 4 just add them one by one! Its just aase of editing
the config file... In fact you could eveb make a config applet to create
the xml entries as your first project!

> My question before I start is whether or not using an XML format for the
> individual file formats is the way to go,

I'd say definitely its exactly ythe kind of thing XML is good at.

> if I have to anticipate every little thing in the file formats before 
> hand.

The whole point of XML is you can modify the file content and the
legacy applications will parse out the bits they need and the new
apps will read both the old bits and the new bits. XML is often
over-hyped and over-used but for this kind of task it is absolutely
perfect IMHO.

> I have zero experience with XML at this point,

Investigate ElementTree - its much easier than the standard xml dom
and sax parsers that ship with Python.

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list