Factory for arrays of objects in python

Posted by Vorac on Programmers See other posts from Programmers or by Vorac
Published on 2013-08-31T06:50:39Z Indexed on 2013/10/22 22:02 UTC
Read the original article Hit count: 211

Ok, the title might be a little misleading.

I have a Window class that draws widgets inside itself in the constructor. The widgets are all of the same type.

So I pass a list of dictionaries, which contain the parameters for each widget. This works quite nicely, but I am worried that the interface to callers is obfuscated.

That is, in order to use Window, one has to study the class, construct a correct list of dictionaries, and then call the constructor with only one parameter - widgets_params.

Is this good or bad design? What alternatives does the python syntax provide?

© Programmers or respective owner

Related posts about python

Related posts about dependency-injection