in reply to Re^3: Module Organization
in thread Module Organization
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Module Organization
by Your Mother (Archbishop) on Oct 13, 2010 at 22:11 UTC | |
I definitely think it could be. It's a design decision, of course, and however you prefer to code is the best way at first. Here's a what might be a better analogy: file types. You could definitely have a Perl module family for them where you had FileType::Text, FileTypeXML, FileType::Executable::Perl, etc but you'd end up with way too many, obviously, and then you'd also end up stuck trying to accommodate data types that are half-in-half-out of filedom, FileType::ApplicationVnds, FileType::OctectStream... When you consider that, MIME::Types is obviously superior and a natural partner for whatever specific datastore (file, scalar, stream, db record) or parser. And since you happened to have hit something I'm interested in, here's a prototype to see one way it could be done. I left out Moose roles and traits as they get kinda hairy. This has some idiomatic Perl in it but also a nice terse tour of some really cool nooks.
Sample output-
I'm kinda glad I am out of time today. This probably would have eaten up a few hours. :) As it is, that took me almost exactly 30 minutes to put together (I have an RPG background though, obviously). Viva la Perl! | [reply] [d/l] [select] |
by Dwood (Acolyte) on Oct 13, 2010 at 23:15 UTC | |
The only problems that I have with reading that code are the +symbol, example: +? and I have no idea how to use has As I've never seen it anywhere... You mentioned that moose got hairy however I am told by others in this thread I should use it for my objects...also, is there a list of available terms anywhere for "is" and "isa" ? | [reply] [d/l] [select] |
by Your Mother (Archbishop) on Oct 14, 2010 at 14:37 UTC | |
If I had time I'd write up a full description and some comparisons of the techniques and idioms. I don't. :( The good news is the Moose docs are pretty darn good. Start on the main Moose page and then walk through as many of the Moose::Cookbook entries as you can. The + in the +shift->$method statements is probably too idiomatic to ask you to discover on your own.
Just so you know, many hackers here will tell you that this is Moose gets conceptually hairy; ask someone to explain the finer points of traits versus roles and the dangers of multiple inheritance to get a feel for that. Moose itself is a joy and, I argue, the clearest path through this problem space and I highly recommend it. | [reply] [d/l] [select] |
by Dwood (Acolyte) on Oct 20, 2010 at 21:53 UTC | |