<?xml version="1.0" encoding="windows-1252"?>
<node id="181131" title="Re: ?Re: Re: ?Re: RFC: Class::DispatchToAll" created="2002-07-11 16:19:23" updated="2005-02-14 23:32:35">
<type id="11">
note</type>
<author id="101964">
domm</author>
<data>
<field name="doctext">
&lt;i&gt;If a class has a get_fields, I'd expect it to return all appropriate fields.&lt;/i&gt;
&lt;p&gt;
I do not want to write 100 accessor methods in each and every class, telling all those methods where to look for the data.
&lt;p&gt;
Instead, I have &lt;b&gt;one&lt;/b&gt; general accessor (&lt;i&gt;get_config&lt;/i&gt;) in &lt;i&gt;App&lt;/i&gt;. Through normal Perl inheritance, every class can access it.
&lt;p&gt;
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?
&lt;p&gt;

&lt;i&gt;Perhaps you don't get why "extending" and "overriding" are useful.&lt;/i&gt;
&lt;p&gt;
I know Perl OO quite well. Overriding is completly clear to me, but what do you mean by "extending"? Something like 
&lt;p&gt;&lt;code&gt;
sub method {
    my $self=shift;
    my $return=$self-&gt;SUPER::method;
    # do something
    return $return
}
&lt;/code&gt;

&lt;p&gt;

&lt;i&gt;You are breaking that model.&lt;/i&gt;
&lt;p&gt;
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...
&lt;p&gt;
&lt;i&gt;At that point, don't call it OO programming any more. You are merely aggregating through hierarchies, turning "IS A" into "HAS A" relationships.&lt;/i&gt;
&lt;p&gt;
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.
&lt;p&gt;
&lt;i&gt;This will scare every single maintenance programmer that has to look at your code. Please don't do that&lt;/i&gt;
&lt;p&gt;
Currently, &lt;b&gt;I&lt;/b&gt; 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.
&lt;p&gt;
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.&lt;p&gt;

&lt;code&gt;
--
#!/usr/bin/perl
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&amp;&amp;print$_.$/}
&lt;/code&gt;</field>
<field name="root_node">
180852</field>
<field name="parent_node">
181046</field>
</data>
</node>
