Hello All,

I want to  build some classes by optimizing their design.
But I want to keep quite 'simples'. I have a XML  document
which represents let's say some rules (id, description, value).

My first idea is to create an *docrules* class which holds my document.
This class will use 2 other instances from 2 respectives classes
reader and writer. The main method of  reader is get().
The main method of writer is write(). To resume I have:
------------------------------ ----------------------- - docrules ----------------------------------- reader - ------------------------------ ----------------------- - filename - - file - - ---------------------------- ----------------------- - - - get() - - ------- -----------------------
                  ------------------------------     -
                                                     -
- ------------------------ ------------------------------- writer -
                                                                                
   ------------------------
                                                                                
   -      file           -
                                                                                
   ------------------------
                                                                                
   -      write()     -
                                                                                
   ------------------------

The *docrules* will do the parsing (*xml.etree* very effective)
and create the reader and the writer instance.
I want to create 2 others classes (or more) more specific which have
more the knowledge about the XML documents structures.
*SpecificRuleReader*, *SpecificRuleWriter* which are deriving resp.
from Reader and Writer which hold resp. *getSpecificRules*() (use of get('/tag1/tag2/tag3/specificTagRules') and a* writeSpecificRules*():

----------------------------- ---------------------------------
      reader                                             writer
----------------------------- ---------------------------------
            ^                                                   ^
             |                                                    |
------------------------------- -----------------------------------
*SpecificRuleReader* *SpecificRulesWriter*
------------------------------- -----------------------------------
*getSpecificRules*() *writeSpecificRules()*
-------------------------------- --------------------------------------

My purpose is to separate as far as possible XML representation from
core classes. I will have certainly more SpecificrulesReader/Writer
classes becauses the document is huge and several discipline rules
will be adressed. I don't want necessarily have 2 big classes which
know everything about XML document because I will have too many
methods.

So, for if anybody has this kind of experience or any design pattern idea,
I will be enchanté.

Regards
Karim

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to