When I'm playing around in Smalltalk of course this isn't really a problem. Need to subclass? Just tell the browser that that's what you want to do (or the refactoring browser if you've got it) and away you go. The image just handles it.
In Perl it's a tad trickier. If you stick with the 'one file, one package' rule, you can end up with loads of tiny files and a dependency issue because, somewhere you need to add an appropriate set of use statements (hopefully you can just do that in your parent class). And if you go with multiple classes per file, what happens when one of your subclasses gets really big and you have to move it out into its own file; you end up introducing an inconsistency of handling that can catch you out later.
I wonder if there's a case for adding an import method into either UNIVERSAL or your application's base class that would allow you to do tricks like:
So, is that insane? Or should I go away and write it?# Load SomeClass, SomeClass::Subclass, and SomeClass::AnotherSubClass use SomeClass qw/::SubClass ::AnotherSubClass/; # Load SomeOtherClass and SomeFullyQualifiedSubClass::Name use SomeOtherClass qw/SomeFullyQualifiedSubClass::Name/; # Load all classes 'below' StateClass in the namespace use StateClass '*';
In reply to Loose coupling good...
by pdcawley
in thread Evolution, v2.0
by mstone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |