4 ms·
> Also, any api/library that lets you create an object that is > unusable because specific methods to set up values haven't > been called yet is very error pr
by estebank 13y ago
> Also, any api/library that lets you create an object that is
> unusable because specific methods to set up values haven't
> been called yet is very error prone.
That's what the Builder pattern[1] is for, avoiding the instantiation of incomplete objects.
I've thought about the appropriateness of that pattern to Python, and so far what I've come up with is merely to use optional named parameters for private/simple classes and Builder classes for public/brittle/robust classes/APIs.
[1]: http://en.wikipedia.org/wiki/Builder_pattern http://en.wikipedia.org/wiki/Builder_pattern