mercredi 25 octobre 2017

Programming dependencies/relationships in python

I am designing a class in python whose properties have a mesh of interdepencies.

Say like it has a property A. When A is set to True then properties B and C can be used. Or else they cant be used. Property B and C may be of any type. May be a boolean or int or string or any custom class.

Also say if B is enabled then we can have either properties D or E or F ( a checkbox like behaviour).

How do i design such dependencies in python class?.

Also i may have similar classes which have such dependencies.. So i am thinking of making a metaclass or baseclass or template like design where user will specify dependencies and code is internally generated.

Any design inputs on how to proceed?

Aucun commentaire:

Enregistrer un commentaire