Archive for the 'patterns/idiom/style' Category

Modules Part II - Strange Brew

« 4 February 2008 | 19:23 | patterns/idiom/style, Ruby Internals, MRI | Comments Off »

This post continues to look at Ruby Modules and their properties.
It’s possible to mix a Module into a second Module which can then be mixed into a class. The result is that an entire Module chain is moved into the a classes inheritance chain with one call to include.

module OneStrand
end

module TwoStrand
include OneStrand
end

class […]



Class Methods Part IV - DSL’s

« 16 November 2007 | 11:25 | patterns/idiom/style | Comments Off »

This last post in a series on Ruby class methods focuses on Domain Specific Languages.
There are many different types of DSL’s. The broadest classification, coined I believe by Martin Fowler, distinguishes between internal and external DSL’s. External DSL’s are languages with a language specific compiler or interpreter. If you are using YACC […]



Class Methods Part III - Structural Duplication

« 12 November 2007 | 14:53 | patterns/idiom/style | 1 Comment »

This post in a series on class methods in Ruby focuses on removing structural duplication.
Whether it’s called OnceAndOnlyOnce or DRY good developers should agree that in the overwhelming majority cases duplication in software is a bad thing. Duplication comes in many forms. The simplest to identify (and remove) is actual text duplication. […]



Class Methods Part II - Annotations

« 26 October 2007 | 12:46 | patterns/idiom/style | 5 Comments »

Part II of this series on Ruby class methods is a look at annotations in Ruby.
The term annotation here refers to a Ruby technique that belongs to the same family as Java annotations, C# attributes, and C compiler directives. These language features are of course not identical, and the class method derived Ruby version […]



Class Methods

« 19 October 2007 | 11:34 | patterns/idiom/style, Smalltalk, Ruby Internals, MRI | 2 Comments »

In my last post I wrote that providing a home for class methods was the raison d’être of the Metaclass. So why go through all the trouble? What are class methods good for? Four uses worth exploring are Object Creation, Annotations, DSL’s, and removal of structural duplication
This post is about Ruby class […]