rod mclaughlinReal programmers don't use SOAP (11 aug 10)
Ruby dries out code (DRY = Don't Repeat Yourself). Instead of the same thing a dozen times like in Java: interface Foot { } class FootImpl implements Foot { } Foot foot = new FootImpl(); foot.shoot(); Foot getFoot() void setFoot(Foot foot) void shoot() throws UnableToShootYourselfInTheFootException etc. and if you are using SOAP <FootRegistrationObjectQueryResultMethod>foot</FootRegistrationObjectQueryResultMethod> Ruby does all this with one line: attr_accessor :foot but industry has come up with a way of (de)generating vast amounts of repetitive code in Ruby It's called SOAP4R. I feel sorry for the guy who wrote it. If you have to use it, note the following hack is needed to make it work, discovered by a workmate of mine: svn checkout http://dev.ctor.org/svn/soap4r/branches/1_5 soap4r-1_5 and at the top of every file generated by wsdl2ruby.rb, add this gem 'soap4r' Oh, I forgot the comments. Just as Java needs comments like this /** @class Foot */ above a line of code like this class Foot code generated by SOAP4R has lots of this # SYNOPSIS Shoot(parameters) So industry has once again saved programmers from themselves. We all started adopting a language which was so productive it would make us all unemployed except for three guys named 'Rohit' in Bangalore, but thanks to SOAP, we can stay off the dole queue. However much you try to treat XML as objects, I find you always end up having to manipulate the raw data. With SOAP4R, it took me a while to find out where the strings are. In the process, I learned how to override any method in any gem. Put a Ruby file in config/intializers, and it gets loaded at startup. You may also refer to it from other files, like this: require File.dirname(__FILE__) + '/../../config/initializers/our_code' In my case, our_code.rb contains a method overriding something from processor.rb in SOAP4R: module SOAP
Back
|