Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

•Re: Re: ?Re: RFC: Class::DispatchToAll

by merlyn (Sage)
on Jul 11, 2002 at 15:31 UTC ( #181046=note: print w/ replies, xml ) Need Help??


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

Then I call dispatch_to_all('get_fields')
This is where I lost you. If a class has a get_fields, I'd expect it to return all appropriate fields. If it has overridden a base class method of the same name, then there's a reason for that, so it should either call all the immediate base class methods and derive an appropriate response from that, or simply ignore those and riffle through it's own data to produce the result.

Perhaps you don't get why "extending" and "overriding" are useful. You are breaking that model. At that point, don't call it OO programming any more. You are merely aggregating through hierarchies, turning "IS A" into "HAS A" relationships. This will scare every single maintenance programmer that has to look at your code. Please don't do that. All the studies show that most of corporate software money is spent on maintaining, not creating, the software. You have just spent a whole lot more money than you even imagine.

-- Randal L. Schwartz, Perl hacker


Comment on •Re: Re: ?Re: RFC: Class::DispatchToAll
Re: ?Re: Re: ?Re: RFC: Class::DispatchToAll
by domm (Chaplain) on Jul 11, 2002 at 20:19 UTC
    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$_.$/}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-07-25 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls