http://www.perlmonks.org?node_id=181131


in reply to •Re: Re: ?Re: RFC: Class::DispatchToAll
in thread RFC: Class::DispatchToAll

If a class has a get_fields, I'd expect it to return all appropriate fields.

I do not want to write 100 accessor methods in each and every class, telling all those methods where to look for the data.

Instead, I have one general accessor (get_config) in App. Through normal Perl inheritance, every class can access it.

So, how can this one general method know which values to return? Is there a "standard" way to do this? Or is my architecture completly screwd?

Perhaps you don't get why "extending" and "overriding" are useful.

I know Perl OO quite well. Overriding is completly clear to me, but what do you mean by "extending"? Something like

sub method { my $self=shift; my $return=$self->SUPER::method; # do something return $return }

You are breaking that model.

I know. I break it by intention, because it doesn't fit my needs. And as TheDamian is doing something similar (NEXT.pm), it seems that I am not the only one with that need...

At that point, don't call it OO programming any more. You are merely aggregating through hierarchies, turning "IS A" into "HAS A" relationships.

I am a so-called "accidental programmer" (i.e. I didn't learn programming at university), and while I am quite aware of OO-methodology, I cannot tell whether this is still OO or not.

This will scare every single maintenance programmer that has to look at your code. Please don't do that

Currently, I am maintaining an old version of this App (written by me, so it's my fault...). In the old version, all those fields are specied in there own class. I can tell you from hourlong search-and-replace-sessions that it this is quite a pain to maintain, as I have to wade to a lot of config files and change/add some values, if I change something in the whole App.

It would seem much clearer to me if each class only adds its specif stuff (or changes already defines stuff). This is what I hope to accomplish with Class::DispatchToAll.

-- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}