[Dbix-class] RFC: Possibly cleaner output for DBIC::Schema::Loader dumps
Brandon Black
blblack at gmail.com
Fri Jul 21 10:15:13 CEST 2006
On 7/20/06, Nilson Santos Figueiredo Junior <acid06 at gmail.com> wrote:
> The first thing I do before adding my own code to the generated schema
> classes is to replace all __PACKAGE__ occurrences to $pkg and add
>
> my $pkg = __PACKAGE__;
>
> at the top of the file. I've seen someone else doing it and I thought
> it made my schema classes a little bit more aesthetically pleasing so
> it became one of my own best practices.
>
I'm not sure how I feel on this. I haven't ever noticed this
technique before. My gut feeling is that I don't particularly like
it, even though it does free up some line length. I suspect there are
cases where $pkg just can't replace __PACKAGE__, although probably not
in this set of output :)
> I also think that some line breaks here and there make a lot of
> difference in code that will actually be handled by human beings.
>
> So, attached you'll find a patch for DBIx::Class::Schema::Loader::Base
> (against trunk) that implements these changes. I don't know if this is
> generally seen as a good practice (I don't know about any reasons why
> it shouldn't) but I've scared enough people with that __PACKAGE__
> madness to have it lurking around my own code. But I guess this really
> boils down to what everyone else prefers (and, maybe more importantly,
> what blblack prefers ;-) ).
I don't actually use Schema::Loader on my own projects anymore, and
haven't in quite some time, so I don't really have much personal stake
in these things.
>
> I also thought about maybe adding some comments above each of the
> generated classes "sections" (e.g. columns, relationships, etc) since
> it might help people who are just starting using the module and it's
> is also something I usually manually add. But these aren't included in
> the patch since I wasn't sure about the best wording.
>
Like the blank lines, comments would definitely be nice. The harder
problem is the fact that Data::Dump, while far better for the task
than Data::Dumper, still produces very ugly output statements for us
compared to human DBIC code like we have in the Manuals.
Things like using qw// where appropriate, and single-quotes where
appropriate too. Then again, I feel anyone who cares that much will
probably just do a series of mechanical cleanups on their own source
after generating.
-- Brandon
More information about the Dbix-class
mailing list