I must say that this looks interesting and I hope to have time to look at it more closely. I do like your idea of eventually making the style configurable as I am seeing method names being generated as "StudlyCaps" instead of "separated_with_underscores", which is generally a more Perlish thing to do (see "perldoc perlstyle").

The one thing that really interests me about this is the potential to create a "standard" style for a particular shop. It can be nothing short of frustrating to have four programmers design four completely different styles of interface for modules going into a single project. I can see this alleviating this problem and, as you pointed out, reducing the overall number of coding errors. Code generators are a Good Thing.

Code comments: a proper test suite would be a good thing. I'd recommend biting the bullet and using Test::More. It's very easy to use and you may just get hooked. I also find that much of your code spans more than 80 columns. This will make it difficult for some who would wish to collaborate to work on your code as they frequently have editors set to this width.

Refactoring is also good, but a proper test suite will make this easier. For example, in Factory.pm, your method &createAttributes has a variation of the following construct repeated six times. Surely that can be reduced.

require PerlBean::Attribute::XXXX; import PerlBean::Attribute::XXXX; return PerlBean::Attribute::XXXX->new($opt);

I'm also wondering about the following line in your constructors:

bless ($self, (ref($class) || $class));

Is there any reason for that? Typically, if someone wants to call the constructor on an existing object, it's for cloning the object, yet I don't see this facility used anywhere. Did I miss something?

Summary: This was only a few minutes of glancing through the code, so I could have missed a lot, but I think this is an interesting idea and I'd like to see more of it. Keep us posted.

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)


In reply to Re: Perl code generation with PerlBean by Ovid
in thread Perl code generation with PerlBean by zoccav

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.