I am currently having an issue concerning best practices where I essentially am trying to figure out the best method for exchanging instantiation settings to an arbitrary function.
At the moment, I use a setup function responsible for constructing multiple Camera objects (the specifics details of the function are not of huge concern).
def setup(self, cameras: dict):
...
This particular dictionary takes the form of...
{
"hwid_1": {
"type": integer,
"fov": integer,
...
},
"hwid_2": {
"type": integer
...
},
"hwid_3": {
...
}
}
Where each hwid
corresponds to a separate physical camera and setup
is responsible for instantiating a new Camera
for each respective id.
Currently, setup()
is also responsible for validating the schema of the input dictionary using JSON Schema and works exactly as expected.
The problem I am having with this approach is that the layer of abstraction introduced makes it difficult for other developers to know the format of the cameras
argument without first consulting the relevant schema.
Are there any other approaches I can take to help make the schema of the input dictionary more explicit or is this an inherent limitation of attempting to instantiate an array of objects with different attributes?