DBIx::Class::Schema::Critic and parameterized roles

I originally started DBIx::Class::Schema::Critic as a code sample for a job application, but I thought it was worth releasing and continued independent development. Inspired by Perl::Critic, it's a package for comparing relational database schemas against a collection of best practice policies using the DBIx::Class Object/Relational Mapper.

At mst's behest I converted it from the Moose object system to his more lightweight Moo. But now that I've accumulated a few policy modules I'd like to refactor their commonalities out into roles.

Trouble is that Moo doesn't have an equivalent to Moose's MooseX::Role::Parameterized, and I can definitely see use for that in creating a bunch of similar roles for each DBIx::Class object a policy applies to.

So what to do? Can/should I port parameterized roles to Moo, while avoiding the overhead of a meta-object protocol like Moose's Class::MOP (which Moo explicitly rejects)? Or just make a bunch of more-or-less identical roles that differ only in name and attribute content, accepting the repetition as the price of minimalism?

5 Comments

Please please please do not write a MooX::Role::Parameterized. If you need parameterized roles, use Moose.

Very clever! Coincidentally, I'm starting a fresh project with DBIx::Class, so I can't wait to try the Schema::Critic.

I've been thinking about porting Perl::Critic to Moose (or Moo or Mouse), so I'm very curious to look at your implementation.

-Jeff

Leave a comment

About Mark Gardner

user-pic I help professional Perl developers to engineer modern, disciplined applications in the cloud so they can become experts that write easy-to-maintain code with confidence, increase their relevance in the market and get the best positions, high salaries, and work on interesting projects.