George Sakkis wrote:
Have you considered a 'macro' solution composing source?


Can you elaborate on this a little ? You mean something like a
template-based code generating script that creates all the boilerplate
code for each version before you start customising it ?

I was thinking more along the lines of repeatable code generation.
I started from this idea: http://groups-beta.google.com/group/comp.lang.python/msg/77ef889e9f99696c
which is a straightforward wrapping case, but illustrates source code composition/generation.


Now given that you have:
#World1.py

class Field:
    ...
class Movable
    ...
etc...


#Then in World2Delta.py

class FieldDelta:
   """just the classes that have changed"""
   def somemethod(self):
    """just the methods that are added or changed
       you could even have nomenclature for method deletion, (a lack which
       sometimes bugs me in OO schemes)"""
        etc...


then you have a 'makefile' that generates a new module for each of your worlds

#makefile.py

def generateWorld(baseworld, delta, newworld):
    """reads two modules:
       baseworld defines the 'superclasses'
       delta defines any changes to these
       writes module newworld, that contains complete
       source for all the classes in the model, with no
       external dependencies
    """

I haven't tried it, but I'm sure it is fairly straightforward to implement (and very easy to test).


This could be
an option, though you'd better be pretty sure that the template is
frozen; you don't want to go back and fill in the template more than
once !

I envisage something that could be regenerated at will, simply by re-running the makefile.


The thing that would need to be frozen is the inheritance graph within each world. If you want to change that between versions, that would make generateWorld much more complex.

The general advantage that I see with this approach is that whatever the hoops you have to jump through to get the makefile process working right - the result is extremely simple to verify. You would also probably get better performance, by avoiding so much subclassing (not that you mentioned that as factor, but...)

Michael












-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to