I recently listened to “Uncle ” Bob Martin giving a podcast on Software Craftsmanship on Software Engineering Radio, and decided to pick up his book Clean Code – A Handbook of Agile Software Craftsmanship. I was struck by the forward by James O. Coplien of Denmark on the 5S Principles and how they tied to [...]
Archive for February, 2010
Clean Code and the 5S Principles
Posted in Development Techologies, The Softer Side on February 27, 2010 | 1 Comment »
Fluent Interfaces in Ruby
Posted in Development Techologies on February 26, 2010 | Leave a Comment »
I had a chance to look at what Neal Ford had to write on Fluent Interfaces in his book The Productive Programmer. Granted, I heard him cover it before at one of his presentations at the No Fluff Just Stuff conference in Reston, VA. Basically, fluent interfaces have setter functions return self (or this in [...]
Using SED for Variable Replacement
Posted in Development Techologies on February 24, 2010 | Leave a Comment »
I was writing a KSH script with the following snippet: exercises=”ex1 ex2 ex3″ for exercise in exercises; do mkdir $home/$exercise filename=Target${exercise}Config.xml done The problem was I did not want the file to be named Targetex1Config.xml, but TargetExercise1Config.xml, respectively. So, I wondered if it was possible to do double-dereferencing (i.e., go from exercise to ex1 to [...]
Safer Monkey Patching
Posted in Development Techologies on February 22, 2010 | Leave a Comment »
General Monkey Patching In Java, classes are defined up front, compiled into bytecode, and remain unaltered. Every instance created from a class adheres to that class. Of course, Ruby is different. In Ruby, you can define a class and later redefine it (and of course, you can modify individual instances of a class so that [...]
Ruby Metaprogramming – Dynamically Defining Classes and Methods
Posted in Development Techologies on February 18, 2010 | Leave a Comment »
The following code uses a class factory to create a new class along with getter and setters for the fields passed into it: class ClassFactory def self.create_class(new_class, *fields) c = Class.new do fields.each do |field| define_method field.intern do instance_variable_get(“@#{field}”) end define_method “#{field}=”.intern do |arg| instance_variable_set(“@#{field}”, arg) end end end Kernel.const_set new_class, c end end ClassFactory.create_class [...]
How Ruby Differs From Java
Posted in Development Techologies on February 15, 2010 | Leave a Comment »
The biggest difference really comes down to metaprogramming. While Java offers introspection (which was a major step up from C++), Ruby offers the ability to dynamically define new classes and methods without recompilation. Additionally, the ability to hook into a module being included or a new class being sub-classed combined with metaprogramming adds extremely powerful [...]