in reply to Do I need a Factory Class At This Point?

To provide a counterpoint to the "Perl doesn't usually need factories" replies, I use a factory in PDF::Template to manage the nodename-to-classname mapping. This way, I can do something like:
my $obj = $factory->create_element( $node_name, @args ); # Check to see if $obj represents a 'foobar' node if ( $obj->isa( 'foobar' ) ) { # Do something }
This is important to me for three reasons:
  1. My users can register new nodenames and the factory manages that
  2. I have some classes that can handle more than one nodename. For example, IF and CONDITIONAL are aliases to each other and are both handled by PDF::Template::Element::Conditional.
  3. In most of the code, I need to differentiate what's a container (can have children) and what's an element (can't have children). However, in the parsing code, I don't care about that (because validation is handled somewhere else).
Does that help?

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?