nexusformat / features

Work on NeXus features and recipes by the NIAC and friends
0 stars 6 forks source link

Add recipe interface superclass #6

Closed matthew-d-jones closed 7 years ago

matthew-d-jones commented 7 years ago

This adds an IRecipe class, a virtual class which acts as documentation for the interface which a recipe should have. It also allows testing that a recipe implements this interface by using isinstance(potentially_a_recipe, IRecipe). Thanks to __subclasshook__() this is possible without potentially_a_recipe having to explicitly subclass IRecipe.

This is a suggested design change; don't merge it if you don't like it.

zjttoefs commented 7 years ago

I'm not too keen on interface classes in python and at the time @markbasham agreed. I believe we made a conscious decision for duck typing then. This also ups the LOC for the "core" source by over 30% for a slightly nicer exception if you make an obvious mistake. I like simple and short is a friend of simple.