Is that Meta Moose or Moose Meta?

I had an interesting discussion to day with a programming friend of mine and we got onto to topic of metadata and as the last few posts I have made have been using metadata (or at least I hope I was)

My friend comes from a DB background so to him metadata was is and ever shall be just data that describes data, You know what I mean the indexes, fields, types tables ect all the annoying minutia of programming. I of course come at it in a different manner I see it as more of a guide to understanding the data.

Well we both agreed it is at some wishy washy mid point that these two meet and become useful, Our conflict arose because after seeing my last post he mentioned some other code of mine we where working on that use a 'role' to apply meta data to an object something like this


package Biz::Rule::Action::Sale;
use Moose;
use Biz::Rule::Meta;
has 'metadata' =>(
	is		=>'ro',
	isa		=>'Biz::Rule::Meta',  
	default =>sub {Biz::Rule::Meta->new(
                         {type   =>'Action',
		          name =>'Sale',
			 description=>'An Item has been sold to a customer.'})},    
);

Now she asked me,

"Why add this new 'metadata' attribute when you have just showed me that nifty 'MooseX::MetaDescription' trick to add it to the Moose's 'meta' class. Your adding attributes and code when you already have a place to put the metadata in!"

Well I wasn't about to admit that I only stumbled upon this a few days ago not the many months ago I wrote the Biz::Rule and that in fact it might be better, she can find that out when she reads the post.

I could of course follow the standard Perl DIMIWTO practice and show her any number of ways to add and play with Mosse's 'meta' class to achieve the same ends.

What I did do is think for a few seconds before I came up with a better answer.

Well for one this is not data that describes a single 'class' it is data that can be used to describe any number of 'classes' so to me it does not belong in the 'meta' of the Moose class. I look at my metadata attribute for human consumption only. You would never need it to recreate the class for example.

I just use it to express some sort of 'generic' business action on a class. For example 'sale' in a real-estate firm means a whole lot more that 'sale' to a 'vending-machine' even though both are the same action. I may for example what to see all my objects that are tagged (I like tagged better) as a 'sale'

Well in the end we where agreed that the two streams for meta data would be useful as why clutter 'meta' with even more stuff, do a Data::Dumper of meta to see what I mean.

moose-playing.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations