in reply to Re: Constructor/Factory Orthodoxy
in thread Constructor/Factory Orthodoxy
First off, don't do my $class = ref $class || $class; That is poor style. Ignore the fact that 99% of the known world does it that way. It's nearly always wrong.
So why, other than your opinion, are these things wrong?
I would use a Factory specifically. First off, you keep the knowledge of which classes actually exist in one place. I like manifests. It helps us maintenance programmers immensely. Also, as a maintenance programmer, I don't like dual-use functions. They are confusing. Base classes are meant to be abstract. Factories are meant to churn stuff out. Factories and Base classes aren't the same thing.
The example I gave above keeps the knowledge of which classes actually exist in one place (or, rather, it's certainly a convenient place to keep the knowledge of classes but doesn't mandate that the knowledge be kept there). That was part of my illustration. Your concerns about dual-use functions are fine -- though they don't bother me personally I'm just as happy with separate constructor methods and factory methods. I'm interested in hearing more about why you think they should reside in separate classes, however. I also wonder if you could elaborate on why you think Base classes must be abstract. (or do you mean that you should always start with an interface -- which Perl is not necessarily admirably equipped to handle?)
Just cause you can doesn't mean you should.
This teaches me nothing, but it does repeat the orthodox party line.
Thanks for the response,
Matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re3: Constructor/Factory Orthodoxy
by dragonchild (Archbishop) on Feb 26, 2003 at 01:05 UTC | |
by mojotoad (Monsignor) on Feb 26, 2003 at 05:13 UTC | |
by rir (Vicar) on Feb 26, 2003 at 21:58 UTC | |
by herveus (Prior) on Feb 27, 2003 at 20:16 UTC | |
by rir (Vicar) on Feb 27, 2003 at 21:56 UTC | |
| |
by dragonchild (Archbishop) on Feb 26, 2003 at 15:03 UTC | |
by steves (Curate) on Feb 27, 2003 at 05:56 UTC | |
by dragonchild (Archbishop) on Feb 27, 2003 at 14:21 UTC | |
| |
by Abigail-II (Bishop) on Feb 26, 2003 at 22:31 UTC | |
by dragonchild (Archbishop) on Feb 27, 2003 at 14:14 UTC |