Contents

What is Moose?

Moose is a post-modern object system for Perl (specifically, perl5). It is an extension of the p5 object system that implements several modern concepts in OOP, foremost among them Roles and MOP, and is designed to make OOP in perl easier.

Moose provides a mechanism for defining an alternative metaclass or base object class. See here and here for quick examples.

Roles, Interfaces, Classes, or Composition?

Roles

Most interface classes or other utility-like classes (IO functionality, for instance) may be good candidates for a Role instead. in fact, we could convert all interfaces over to Roles fairly easily. This may cut down on inheritance-related issues within BioPerl.

See chromatic's blog series on Perl roles at Modern Perl Books starting here. --MAJ

Composition

Bio

Lazy instantiation

Types and type coercions

Moose has a rich data type system that allows for definition of custom types. They allow for clean input validation in a systematic, coherent way throughout all methods of a distribution. This helps to factor out all common type validation and error handling code on data input, making methods shorter, cleaner and more consistent.

Moreover, type coercions can be used to interconvert between different compatible types in an automatic way, increasing the DWIMness of the API.
For instance, a method might act upon a Bio::Seq object. Defining proper type coercions, the method could automatically accept a sequence scalar, a Bio::SeqIO object, a filename scalar, a Bio::SimpleAlign object, etc; doing whatever it takes to get a Bio::Seq object from the input given.