rmnldwg / lymph

Python package for statistical modelling of lymphatic metastatic spread in head & neck cancer.
https://lymph-model.readthedocs.io
MIT License
5 stars 4 forks source link

Synchronization is unreadable and error-prone #74

Closed rmnldwg closed 4 months ago

rmnldwg commented 4 months ago

I think my attempt of synchronizing the attributes of the ipsi and contra instances in the Bilateral model class are bad: It's hard to understand what's going on, the state of some objects changes "magically", one cannot even look up what is synchronized, and I am loosing my mind over it.

However, I think there may be simpler and more elegant solution: A SynchronizerMixing, in a similar fashion to the DelegatorMixin: Such a mixin class could dynamically create methods and properties that keep e.g. some ipsi and contra attributes in sync. The advantage would be that the entire synchronization is now the responsibility of the Bilateral (or Midline) class. The ipsi and contra objects would - on their own - still work as expected and not leak anything to each other via obscure synchronization callbacks.

This could be much easier to test, as well.