Run-time Class Composition With Moose

Tags:

Originally posted as: Run-time Class Composition With Moose on blogs.perl.org.

Moose is great! At its very basic, it simplifies the boilerplate required to create Perl objects immensely, providing attributes with type constraints, method modifiers for semantic enhancement, and role-based class composition for better code re-use.

Moose is built on top of Class::MOP. MOP stands for Meta-Object Protocol. A meta-object is an object that describes an object. So, each attribute and method in your class has a corresponding entry in the meta-object describing it. The meta-object is where you can find out what type constraints are on an attribute, or what methods a class has available.

Since the meta-object is a Plain Old Perl Object, we can call methods on it at runtime. Using those meta-object methods to add an attribute would modify our object, adding that attribute to the object. Using Class::MOP, we can compose classes at runtime!

Continue reading Run-time Class Composition With Moose...

Chicago.PM Report - App::Services by Sean Blanton

Tags:

Originally posted as: Chicago.PM Report - App::Services by Sean Blanton on blogs.perl.org.

This month's technical presentation at Chicago Perl Mongers was about Sean Blanton's project called App::Services. It's an interesting project that uses Bread::Board to access resources like databases, logging, ssh, and others.

Continue reading Chicago.PM Report - App::Services by Sean Blanton...

Chicago.PM - Beyond grep - Expanding the Programmer Toolset

Tags:

Originally posted as: Chicago.PM - Beyond grep - Expanding the Programmer Toolset on blogs.perl.org.

How often have I told myself, "I'll kludge this now and rewrite it later"? And how many times did I actually go back and rewrite that kludgy bit? "Too often" and "not enough". Many job postings include the phrase "update legacy applications," as a euphemism for "rewrite poorly-designed spaghetti." The Y2K problem was a huge exercise in code out-living the developer's plan, with a healthy dose of cargo-culting thrown in. Lately, I've been learning to plan for a likely possibility: My code will survive to haunt my bug lists and my resume for a long time.

Continue reading Chicago.PM - Beyond grep - Expanding the Programmer Toolset...