[Tutor] help with refactoring needed -- which approach is morePythonic?

Alan Gauld alan.gauld at freenet.co.uk
Sat Feb 12 13:51:42 CET 2005

> It still seems to me that the actual updating of the article should
> a Node method (it is the Node object's article that is being
> after all).

Yes, the owner of the data should update it.

> Call it node_linkify. The new thought is to create two new
> methods for the TP_file class:
> - One to build a dictionary with Node titles as keys and
>    a list of the corresponding unique ids as values.

Which saves searching the node list each time, good idea.
This dictionary would of course be part of the Head or Body
object which manages the Nodes?

> - Another to pass that list into a the node_linkify Node method,
>    once for each Node object of the TP_file.

Since the node knows its own ID and shouldn't know about
the other nodes I wonder if it would be better for the
Body/Head object to pass only what the node needs to
create the links. Or do the links go to *all* the other
related nodes? In which case the dictionary entry is fine.

Alan G.

More information about the Tutor mailing list