in reply to Re: Perl code generation with PerlBean
in thread Perl code generation with PerlBean
Hi Ovid,
Thanks for the very constructive comments and critic.
style configurable ... as "StudlyCaps" instead of "separated_with_underscores"
With styles too, there is more than one way to do it. My sense of style is my own and I find CamelCase saves space (the underscores) -space used to be an issue when 80x24 was the way it was (maybe I'm old fashioned.) And the API isn't an iconic one that justifies short cryptic method names. Then again, I certainly don't want to impose my style. Also, I must admit I haven't read perlstyle (yet.)
I still have to figure out how to do the style precisely. Right now I think it'll be set through a PerlBean::Style object (as opposed to setting specific properties in the PerlBean and PerlBean::Attribute objects.) And yes, the default style will very likely be perlstyle as I see no reason in challenging it. That'll mean an interface change as I think a code generation tool should be written in the default style it offers itself.
My first attempts at style reconfigurability is in the PerlBean::Attribute method setMethodBase () which allows to overrule the standard camel_case to CamelCase mapping (e.g. into _camel_case which would yield to a method name set_camel_case). But I like PerlBean::Style better.
... Test::More ...
I'll have a look at that too.
... 80 columns ...
I know. It happens to me all the time. I dislike splitting strings into multiple lines. I also like to keep my conditions and loop headers on one line which clean TAB indentation. I guess I have to change to 4 space indent.
Refactoring ... Factory.pm ...
I assume you understand that the requires/imports are there to minimize the used resources by requiring and importing only the truly needed files. If I narrow down the problem to the instantiations of PerlBean::Attribute objects I don't see how to do refactoring. But don't hesitate to point me out.
I'm also wondering ... bless ($self, (ref($class) || $class));
Like you more or less pointed out yourself, it's for calling the constructor through an object instance. IMHO if you call the constructor you expect a newly constructed object and not a clone. I'd implement a clone method to clone.
Again thanks for your points and challenges. In any case they contribute to the awareness of the API, keep me alert and are a sign of good vibes.
Right now I am implementing PerlBean::Method that allows to define and document methods/interfaces. When ready this results in more consistent documentation for method inheritance/implementation/overloading.
After that I might write a PerlBean::Collection tutorial and then PerlBean::Style.
I hope my wife and kids too agree with this plan.
Cheers,
Vincenzo Zocca
Vincenzo@Zocca.no.spam.com
remove no.spam to contact me