Standardise on class constructor methods for object creation from different formats #278
Open
5 of 8 tasks
Labels
refactor
Restructure or simplification
Milestone
I propose we use class constructor methods for all methods that instantiate objects from external input formats. This is a common "pythonic" pattern: see for example
pd.DataFrame.from_dict()
,pd.DataFrame.from_records()
.Andy & I have been trying to roll out this pattern across resqpy, but currently we're a bit inconsistent and many classes need to be refactored. It is already implemented in a number of classes, for example
resqpy.well.DeviationSurvey.from_data_frame
.How constructor methods are called by users
Class methods are called from the class directly, without first having to instantiate an object:
This is cleaner than first instantiating a messy "empty" object, and then calling another method to populate the attributes:
Rationale
Example implementation
Checklist
The text was updated successfully, but these errors were encountered: