[Israel.pm] An OOP Pattern Discovered by Accident
shlomif at gmail.com
Sun Jan 28 04:41:27 PST 2007
Hi Oded! And All.
On 1/28/07, Oded Arbel <oded-linux at typo.co.il> wrote:
> On Sat, 2007-01-27 at 23:04 +0200, Shlomi Fish wrote:
> > > Eh. That's the one thing I'm missing when comparing perl to Java :
> > > automated refactoring.
> > Well, there's a difference between automated refactoring and automated code
> > generation, which is what you've mentioned before.
Actually there is a difference. In order to automatically refactor
code one must analyse the existing code and then improve it
automatically programmatically. OTOH, generating code is usually
easier as you're simply generating it and then once its final it need
not be modified any longer.
> > You can automatically
> > generate Perl code if that's what you need,
> Not conveniently - Eclipse writes core for me on the fly as I'm
> programming. I suspect that when you say that I can "generate perl code"
> is that I write some other code to generate more code - during compile
> or during runtime (like you showed in your previous e-mail),
Yes, that's what I meant. Albeit the Perl code I demonstrated is a
case of self-modifying code, rather than offline code generation. So
the code that is passed to the compiler does not have duplicate code.
> while I'm
> looking for something more.. how shall I say it... ehmm... automatic.
> Hey! that's the word I used before, I appear to be repeating myself :-(
It would be helpful if you explained how Eclipse's code generation is
more "automatic". Do you give it a function as a template and then can
generate other functions based on it.
>From a purist POV, they would dislike the idea of having such
duplicate code even if the IDE generates and manages it. It's still
duplicate code. My perl example can be encapsulated in a module and
then one can say something along the lines of:
use base 'Class::MakeDelegates';
To generate all the delegated methods. This way a maintainer of the
code (using any text editor or IDE) can simply add or remove entries
from the list, and not have to modify several instances of duplicate
> > but automatically refactoring it
> > is not possible at the moment, except for some basic stuff using
> > Devel::Refactor.
> It would be cool if someone would integrate this with some editor, which
> Devel::Refactor seems to be begging for - it looks to me rather useless
> w/o such integration.
I think Eclipse's EPIC Perl-development environment has integrated
this. I haven't tried it yet.
> > Moreover, the refactorings provided by Eclipse and other
> > Java IDEs are only a subset of the refactorings covered in the "Refactoring"
> > book by Martin Fowler.
> I'll take 10% done over 0% done any day of the week, thank you very
Indeed. What I meant to say is that you still have to perform some
refactorings by hand, even in Java.
Shlomi Fish http://www.shlomifish.org/
If his programming is anything like his philosophising, he
would find 10 imaginary bugs in the "Hello World" program.
More information about the Perl