I am looking to integrate a number of objects that need to notify each other of their state changes. I am looking for design pattern suggestions on how to proceed.
The problem space is that of a branch of biology called 'phylogenetics'. The main objects in this problem space are:
These objects interact with one another during the course of a typical phylogenetic analysis, which might consist of:
- Collecting data
- Shoe-horning it into one or more matrices
- Inferring one or more trees from the matrices
- Analyzing the fit of the data on the trees. This might include things like removing outliers, fixing typos in taxon names, and other things in desparate need of a mechanism to preserve referential integrity between trees, taxa and matrices.
There's a number of packages on CPAN that deal with this kind of research: Bio::NEXUS
(I wrote Bio::Phylo, and I'm working with the authors of Bio::NEXUS) and bioperl
(the 500-pound gorilla with which we want to stay compatible).
If you care to look at these packages, you'll notice that there are implementations of the tree, matrix and taxon objects I described, but no larger framework that deals coherently with the relationships between them. One part of the integration I am trying to achieve is a situation where changes to a taxon object cascade through to the matrix and tree objects that refer to this taxon. Likewise, changes in the matrix should be reflected in the tree and (sometimes) vice versa.
The problem I have is that I can't quite conceive of the right architecture to keep referential integrity between the different objects I'm dealing with. I am thinking of something like the Observer pattern, but I'm not sure if that's entirely appropriate (observing and handling goes in multiple directions between the objects. I fear spaghetti.) I am very eager to hear your suggestion and comments.