The concept of a factory class makes sense in statically typed languages like Java, where there may be multiple implementations of an interface and you want to hide the process of picking and instantiating an implementation of the interface in such a factory. In Perl, classes can take whatever arguments and return whatever values they please, so this concern applies less often. This means one should spend a little more time thinking about a useful and extensible API and class hierarchy, but I think one has to worry less about the implementation :-) In your case, either of the APIs you showed seems fine to me, however:
since its essentially a factory returning objects of it's own class
I don't see how this follows from your description or code - why would a factory return objects of its own class? Why shouldn't the factory return objects of a different class?
In reply to Re: Using a factory class to return objects of the same class
by haukex
in thread Using a factory class to return objects of the same class
by Amblikai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |