This is a set of examples to accompany an article published on the O'Reilly Programming Blog.
- java/InterfaceFarm.java
-
Java implementation using interfaces.
- java/DelegationFarm.java
-
Java implementation using interfaces plus the delegation pattern.
- ruby/mixin-farm.rb
-
Ruby implementation using mixins.
- ruby/traitor-farm.rb
-
Ruby implementation using traitor. This doesn't actually seem to work on my machine.
- php/trait-farm.php
-
PHP 5.4+ implementation using traits.
- perl5/moose-farm.pl
-
Perl 5 implementation using Moose.
- perl5/moo-farm.pl
-
Perl 5 implementation using Moo, a small OO framework that promises "almost -- but not quite -- two thirds of Moose". It's almost line-by-line identical to the Moose implementation.
- perl5/tiny-farm.pl
-
Perl 5 implementation using minimalist libraries Role::Tiny and Class::Tiny.
- perl5/mop-farm.pl
-
Perl 5 implementation using mop, Steven Little's reimplementation of a subset of Moose, intended for inclusion in the Perl core.
- perl6/role-farm.pl6
-
Perl 6 implementation using the language's native roles.
- python/abc-farm.py
-
Python example using multiple inheritance from abstract base classes.
- scala/TraitFarm.scala
-
Scala implementation using the language's native traits.
- javascript/joose-farm.js
-
Port of the Moose implementation to Javascript and the Joose library. Works with Ubuntu's
/usr/bin/rhino
; with minor adjustments will work with most other implementations of Javascript.
I'd appreciate contributions for any programming languages I've missed; in particular any where this sort of thing can be done especially elegantly.