2 ms·
Factory classes make less sense in a language with first class functions, but Factory functions are handy sometimes. As you can see in this example of a Factory
by icebraining 15y ago
Factory classes make less sense in a language with first class functions, but Factory functions are handy sometimes. As you can see in this example of a Factory function in Python from the standard library[1], it can be useful to return different subclasses depending on the arguments, but it doesn't have to be heavyweight like in Java.
[1]: http://docs.python.org/library/collections.html#collections.namedtuple http://docs.python.org/library/collections.html#collections....