{ |one, step, back| } 21 to 30 of 177 articles WikiSyndicate: full/short

The erubycon Interviews: Anthony Eden Answers   12 Jun 07
[ print link all ]

Anthony Eden’s answers to the erubycon interview questions make up the third installment in this series.

Anthony Eden Answers

Anthony Eden has more than 10 years of experience developing web applications, first with Perl, then Java and now Ruby on Rails. Anthony has developed numerous open source projects over the last 5 years in both Java and now in Ruby. Anthony is currently a project manager and technical lead with Camber Corporation, a government contractor and runs his own company, Aetrion LLC, a data warehouse development company.

Here are Anthony’s answers:

Q: Tell me a little about your background, where you are working and how did you come to start using Ruby?

I am a software developer/project manager with Camber Corporation, a 1400-employee consulting company that services the military and US Government as well as other nations. I also run my own business on the side developing Ruby-based data warehouse solutions for small businesses. I began with Perl in ‘95, started using Java in ‘96, used Python along the way and am now doing Ruby almost exclusively (except for some interest in Erlang). I came to Ruby via Rails and I was skeptical at first, but within a couple of months of using Ruby I became convinced that it could greatly improve my productivity, my team’s productivity and the overall joy of developing software.

Q: What unique opportunities do you see for Ruby in the enterprise?

The prime opportunity is to reduce the amount of code and amount of effort that goes into operating and maintaining various systems used to support Enterprise organizations. The larger an application is the harder it is to maintain. My hope is that the elegance of the Ruby language is seen as an enabler for smaller, easier to maintain enterprise applications that work together, rather than monolithic beasts that can’t be integrated.

Q: What obstacles do you see to getting Ruby used more in enterprise software?

Lack of quality documentation about Ruby and its associated libraries, that is easy to find, for one. Development tools are still an issue, but I actually see Ruby as a catalyst for new development tools that can take advantage of the dynamic nature of scripting languages, rather than something which is seen as an obstacle.

Q: Play oracle for a moment and tell me what you see as the next “Big Thing” in software development.

Distributed parallel processing. A few days with Erlang opened my eyes to the potential of direct support for parallel processing in a language and made me realize that parallel processing is going to be the only way to process the huge amount of data that is becoming available thanks to the “opening up” of a lot of web sites. Google and Amazon are really leading the way here and are representative of where we can go with applications and data integration on a large scale.

Q: What erubycon talk are you most interested in hearing?

- Ruby on Rails with Large Teams

- Stretching ActiveRecord

Thank You

Thanks Anthony.

For more information on the conference, see erubycon.com.

The erubycon Interviews: Bruce Tate Answers   11 Jun 07
[ print link all ]

Bruce Tate is the second featured speaker to provided feedback on our erubycon speaker interviews.

Bruce Tate Answers

Bruce Tate is a kayaker, mountain biker, and father of two from Austin, Texas. An international speaker and respected author, Bruce’s primary focus through the years has remained steady: rapid application development of web applications. He specializes on putting highly effective teams on the most productive and most appropriate technologies.

Q: Tell me a little about your background, where you are working and how did you come to start using Ruby?

I have been programming for about 30 years, and programming for money for the last 25. I worked at IBM for a number of years, got bored, and left to work for a startup which immediately blew up. Then, I was an independent consultant, which was a little like saying “Unemployed, but with business cards.” I did Java development, training, mentoring, and consulting for five years or so, and began to think that things were getting too bloated, too complicated, and unsustainable. Dave Thomas challenged me to give Ruby a try, and I did, and loved it, and hated that I loved it. All of my reputation, my books, and my customers were all wrapped up in Java, but I knew it was not the right language for the types of problems I was trying to solve. I interviewed a bunch of people to understand what was happening, and then decided to write a book about the learning experience. That book, Beyond Java, caused a lot of controversy, but the stuff seems pretty tame these days.

Eventually, I shifted my consulting practice to Ruby full time. I later turned a consulting gig into a full time CTO position at http://ChangingThePresent.org, We’re building a charitable contributions portal. At ChaningThePresent, you don’t just make a donation. You get an hour of a cancer researcher’s time, you make a blind person see, and if you like, you can make that tangible donation in the name of another, and get a customized card to announce your donation. We hope to be the de facto resource for nonprofits on the web. We think we’re well on the way.

Q: What unique opportunities do you see for Ruby in the enterprise?

I do everything in Ruby. As computing power gets less expensive, we need to use more of that power, and let the base programming language do more of the work. Our infrastructure is just about all in Ruby these days.

Q: What obstacles do you see to getting Ruby used more in enterprise software?

We don’t see insurmountable obstacles. We do think tools have room to grow, especially in the area of refactoring development environments. The dependence on so many C libraries, like ImageMagic, is a pain for deployment. And we use Rails, which has its share of warts. Caching in the persistence layer is harder than it needs to be. Migrations don’t scale beyond small teams. But none of these things even dent the long term productivity that we experience. Any framework will lead to its share of technical debt. Rails is no exception. All in all, it’s a fantastic framework.

Q: Play oracle for a moment and tell me what you see as the next “Big Thing” in software development.

I always get in trouble for doing this, but I’ll bite. From a language perspective, we seem to be getting closer and closer to a functional language. Ruby is just one step in that direction. We won’t see major movement in the core language for another 10 years, though… we’re locked pretty hard into a 10 year programming language cycle. I think we’ll continue to converge on a set of frameworks that is over HTML and JavaScript. You can easily imagine one of the HAML-like languages putting a dent in HTML, and one of the AJAX frameworks, either in JavaScript or a langauge that composes it, providing a layer over the browser. It’s becoming clearer that HTML isn’t enough, and JavaScript needs layers on top to be everything we need.

Domain specific languages will be unleashed, and driven from things like IDEA’s language workbench and programming languages and concepts in Ruby. This will take us closer to functional programming languages than we’ve ever been.

From a language and feature standpoint, we’ll see continuations play a bigger role. AJAX is complicating web development again, and we’re going to have to make some simplifying assumptions. AJAX tripped up continuation based models for a little while, but I can easily see an abstraction with better encapsulation that lets AJAX play.

So those are three things that I see in the 5-10 year window. In the more immediate timeframe, we’ll see Ruby continue to push Java on the applications end. No single language will dominate, but a bunch of us have already moved beyond Java. There’s still a place for Java, and C++ or COBOL for that matter. But mind share is moving on. It’s inevitable.

Q: What erubycon talk are you most interested in hearing?

It’s an incredible docket. I can’t pick just one.

Thank You

Thank you Bruce. Folks can get more information about erubycon at erubycon.com.

The erubycon Interviews: Zak Mandhro Answers   08 Jun 07
[ print link all ]

With the erubycon quickly approaching, I have sent a list of 5 questions to several of the erubycon speakers. As their responses come back to me, I’ll publish them here.

Enjoy!

—Jim Weirich

Zak Mandhro Answers

Zak Mandhro is a Senior Manager of Information Management Solutions for BearingPoint (http://www.bearingpoint.com). He is the first of our erubycon speaker interviews.

Q: Tell me a little about your background, where you are working and how did you come to start using Ruby?

I am a Senior Manager at BearingPoint, a global consulting company. My background is custom Enterprise Solutions that utilize JavaEE, .NET, SOA, Portals and Business Intelligence. I came across Ruby while exploring dynamic languages in 2004. I started using Ruby actively after Rails 1.0 release (outside of BearingPoint). We are currently using Ruby for a requirements DSL (http://rubyforge.org/projects/rdil) at a major federal client.

Q: What unique opportunities do you see for Ruby in the enterprise?

Short answer: The bottom-line is richer application at lower cost with faster time-to-market. At the moment, I see two areas where Ruby and Ruby on Rails are particularly attractive. (1) Building departmental database-driven applications, the type that are being serviced by VB, Access and ColdFusion today, and (2) Web services and SOA glue code.

The long answer is here: http://www.sdtimes.com/printArticle/column-20070101-01.html

Q: What obstacles do you see to getting Ruby used more in enterprise software?

We need to have a better deployment and infrastructure story for Rails. Unlike the shared hosting and VPS market, terms like monit, lighty, mongrel and fastcgi are alien to Enterprise data centers. There’s isn’t much in the “Enterprise”-press that would give these products credibility, let alone coverage. Lack of management tools is another area of improvement. We need to get to a point where systems integrators and IT infrastructure staff are familiar and comfortable with Rails deployment. JRuby WAR deployments is one way to get there.

Q: Play oracle for a moment and tell me what you see as the next “Big Thing” in software development.

I think we are already in the midst of the next big thing. “Simplification of Enterprise Software”. Complex and high-priced proprietary Enterprise software will slowly but surely start to lose market share to simpler open-source alternatives. We are seeing a move to openness and simplicity with JavaEE. We are witnessing endorsement of dynamic languages (less code). Over the next 12 to 24 months, we’ll see more simpler alternatives pop-up, mature and become pervasive; hopefully without ending up becoming just as complex.

Q: What erubycon talk are you most interested in hearing?

Must I choose? Here are three quick picks (in no order):

- Security (CAS and OpenID)

- Mingle: Full-scale JRuby

- Keeping Tests Dry

Thank You

Thanks Zak. Folks can get more information about erubycon at erubycon.com.

Chicago RailsEdge Sessions Posted   25 May 07
[ print link all ]

Rails Edge

I’ve been meaning to post about this for a couple of weeks, but with everything going on, there just didn’t seem to be time.

Here’s the news. Registration is open for the next RailsEdge conference in Chicago (August 23-25). Mike and Nicole have posted the session list for Chicago and there are some really great talks lined up for this time around, including a number of new talks that we haven’t done before.

New talks

Chad Fowler will be speaking on “Quick and Clean: Well-Factored Rails”. I really like the emphasis in the Rails community on keeping your code clean (and still beating everyone to market).

Stuart Halloway is adding a talk on Domain Driven Design. Good design is critical to producing a system that flexible and maintainable. Looks like Stu is going to give us the goods on how to do just that.

Justin Gehtland will be talking about JRuby. I was in the JRuby tutorial at RailsConf and the JRuby guys are doing a bang up job of bring JRuby up to speed as a solid platform for rails. If you are in a place that already has Java deployed, then deploying a Rails app has suddenly become as easy as dropping a WAR file on the server. Cool stuff.

And it looks like I will be able to reprise my “DSL: Speaking the Lingo” talk from RubyConf a couple years ago. If anything, the DSL story in Ruby has gotten even stronger than before. And in addition to juggling and Rubiks Cube from the original talk, I have a little extra surprise just for the Chicago crowd.

New Speakers

In addition to all the new talks, we have several new speakers featured at the Chicago venue.

Ezra Zygmuntowicz will be speaking on “Mongrel: Learning how to walk the dog” and “Xen and the Art of Rails Deployment”. Deployment issues seemed to be at the top of the list of concerns at RailsConf and Ezra will help set us straight.

At past RailsEdge conferences, the feedback was strong about having more coverage on the topic of testing. So as not to disappoint, we will have David Chelimsky talk about “RSpec: Behavior Driven Rails” and Mike Mangino will cover “Testing in the Real World”.

See you there

That’s just the new stuff for Chicago. We still have a great selection of topics from previous RailsEdge conferences. See the current schedule for a complete list of topics.

All in all, it looks like a really great lineup of speakers and topics. I hope to see you there.

What Should flexmock(real_obj) Return?   22 May 07
[ print link all ]

Bruce Williams asked this question at RailsConf, and I am soliciting feedback.

Background

First, a little background. There are two possibilities when calling flexmock(). First, you are creating a full mock object:

# Example 1
mock = flexmock("description")
mock.should_receive(...)

A full mock fulfills two roles: (1) it is a target for should_receive to define expectations, and (2) it is a target for normal domain messages when testing.

The other possibility is that you are creating a partial mock (i.e. a regular Ruby object with just a few mocked methods):

# Example 2
real_obj = RealObject.new
proxy_mock = flexmock(real_obj, "description")
proxy_mock.should_receive(...)

The object returned from the flexmock() method is actually a proxy object that can accept should_receive() messages to define the expectations, but does not handle normal domain messages. After all, we have a real object that that handles domain messages.

Partial Mocks

It is clear that when creating a partial mock using the non-block form of flexmock(real_obj), we must return the proxy, else there would be no way to add expectations. But the return value for the block form of flexmock is not so clear.

Consider the following code:

# Example 3
real_obj = RealObject.new
result = flexmock(real_obj) do |mock|
  mock.should_receive(...)
end

Here the proxy object is passed as the block argument. All the expectation setup is done within the block. It is very tempting to write this code as:

# Example 4
result = flexmock(RealObject.new) do |mock|
  mock.should_receive(...)
end

But here is the problem: in example 4 we no longer have a reference to the RealObject instance. The flexmock() method returns the proxy object, not the real object; just as it does in the non-block form.

Bruce’s Suggestions

Bruce suggested changing the block version of flexmock() to go ahead and return the real object. Since the proxy is used in the block, there is no real need for it outside the function. And, I will admit, example 4 is short and relatively clear, especially with those familiar with the returning idiom used in Rails.

The Dilemma

So here is my dilemma. Changing FlexMock so that example 4 works properly is attractive. And I suspect that the return value of flexmock(real_obj) is not ever used in a significant way in existing code, so backwards compatibility should be be only a minor concern. However, changing the return object based on whether or not the method has a block just seems … wrong.

There is precedent for this. In the standard Ruby libraries open(fn) and open(fn) { ... } return different things (an open file for the former and the value of the block for the latter). I’ve never had problems with this behavior in open, so perhaps I am just being over sensitive here.

I told Bruce I would blog the issue and consider the feedback received. So let me know what you think. Should flexmock() be modified to return the real_object when defining partial mocks using the block form?

You can email me (jim@weirichhouse.org) or add a comment using the comments link below.

Joining EdgeCase   14 May 07
[ print link all ]

Hello EdgeCase!

This is exciting news … well, exiting for me at least.

I have just accepted a position with EdgeCase, an agile software firm started by Joe O’Brien, Chad Humphries and Ken Barker located in Columbus Ohio. EdgeCase is focussed on agile software development and delivering Ruby on Rails solutions, a perfect match for my passions, skills and abilities.

I have known Joe for a long time, and we have a deep, mutual respect for each other. I am extremely excited to be a part of his team.

I still have a few remaining responsibilities with Compuware that will be discharged over the next few weeks before starting full time with EdgeCase. I’ve been at Compuware for nearly 12 years and I’ve had some great assignments and really wonderful learning opportunities while working for them. But this chance to work with Joe and the gang is a golden opportunity that I am not willing to pass up.

Color Blind   02 May 07
[ print link all ]

Presented a talk on Test First Design today at work.

I did a Lunch & Learn presentation today at work on the topic of unit testing and Test First Design, included a discussion of the Red / Green / Refactor technique. Unfortunately the red gun on the video projector was bad, ruining all the careful color coding I put in to my slides. So the technique will now be officially called Black / Yellow / Refactor.

Is This a Bad Idea?   23 Apr 07
[ print link all ]

This idea occured to me as I was reviewing a Rakefile recently.

Ugly

Rakefile task comments are a bit ugly. Since I want Rake to report task descriptions, I can’t use regular Ruby comments (which would be invisible to Rake). Instead, Rake will use the desc command, as in:

desc "This task will do something" 
task :do_something do ... end

An Alternative Syntax

While I was reviewing a Rakefile recently, it occured to me it would be entirely possible to write a task comment like this:

-- "This task will do something" 
task :do_something do ... end

You can think of this as a kind of marriage between Ada comments (using—) and Smalltalk comments (using ’”’).

The Implementation

  class String
    def -@
      desc self
      0
    end
  end

Yep, its that simple.

Fortunately, my better judgement took over at that point and this comment style will not make it into Rake. Unfortunately, it didn’t take over in time to prevent me from blogging about it.

Custom Rake Applications   21 Apr 07
[ print link all ]

It’s odd how ideas come to you. I was working on a script unrelated to Rake, when a different way of using Rake occurred to me.

Start / Stop Script

Today a coworker passed on a shell script for staring and stopping a server on a local box. The script was pretty typical. You would type “server start” and “server stop” to bring the aforementioned server up and down. It looked something like this:

#!/bin/sh

SERVER_DIR=/path/to/server/directory

case $1 in
    start)
        pushd $SERVER_DIR
        ./startServer.sh >out.log &
        popd
    ;;

    debug)
        pushd $SERVER_DIR_
        ./startServerDEBUG.sh >out.log &
        popd
    ;;

    stop)
        pushd $SERVER_DIR
        sh stopServer.sh
        popd
    ;;

  *) echo "invalid" ;;
esac

There were a few more options, but you get the drift. Anyways, I wanted to to customize the script a bit and realized that my shell scripting abilities were a bit rusty. So I translated the whole thing to Ruby …

The Ruby Version

The translation was pretty straight forward. The guts of the script looked like this:

ARGV.each do |arg|
  case arg
  when 'start'
    Dir.chdir(WLS) do
          system "./startWebLogic.sh >out.log &" 
    end

  when 'debug'
    Dir.chdir(WLS) do
          system "./startWebLogicDEBUG.sh >out.log &" 
    end

# [... code elided ...]

and so on.

After about the second or third “when” clause in the “case” statement, I realized that I was essentially writing tasks. And we have a perfectly good Ruby tool for managing task based software: Rake!

So why wasn’t I writing this as a Rake script? One reason is that Rake depends on the presence of a Rakefile in the current (or parent) directories. I needed to be able to run any of my server commands from anywhere in the file system, not just from the directory containing the Rakefile.

Fair enough. But there’s nothing preventing me from writing a ruby script that includes the Rake library. We saw something similar in the FindInCode script earlier. The only additional thing we need to do is include the task definitions directly in the script, and then explicit invoke the tasks we need.

The Initial Rake Version

So I abandoned my first cut at a Ruby version and went with this:

#!/usr/bin/env ruby

require 'rake'

SERVER_DIR = /path/to/server/directory

task :start do
  Dir.chdir(SERVER_DIR) do
    sh "./startServer.sh >out.log &" 
  end
end

task :stop do
  Dir.chdir(SERVER_DIR) do
    sh "./stopServer.sh >out.log &" 
  end
end

# [... more task defintions go here ...]

ARGV.each do |arg| Rake::Task[arg].invoke end

Now I have a version that can handle all the task dependency stuff that Rakefiles do, but can be run from anywhere in the file system. Assuming I named the script “server”, I can say:

server start

and the right code gets run. I can specify dependencies between the tasks in the script (e.g. “task :bounce => [:stop, :start]“), and do all the other great stuff that building on Rake allows.

The Improved Rake Version

There are a couple of downsides to the above script. Even though I can invoke the server script as if it were a rake-like command, it doesn’t do everything that rake does. For example, there is no way to get a list of all the defined tasks (.e.g rake -T). In fact, no rake command line options are support in the above code. Neither are the environment variable parameters (e.g. TEST=test_file_name.rb). Furthermore, the error messages are not trapped and handled the way that Rake does it.

Now, all of the above could be manually added to the server script, but a better way is to slightly refactor Rake to better support customer rake applications. The init and top_level public methods were added to the Rake Application class, so now we can write the above script as:

#!/usr/bin/env ruby

gem 'rake', '>= 0.7.3'
require 'rake'

Rake.application.init('server')

SERVER_DIR = /path/to/server/directory

task :start do
  Dir.chdir(SERVER_DIR) do
    sh "./startServer.sh >out.log &" 
  end
end

task :stop do
  Dir.chdir(SERVER_DIR) do
    sh "./stopServer.sh >out.log &" 
  end
end

# [... more task defintions go here ...]

Rake.application.top_level

All we did was add a call to Rake.application.init to initialize the command line parameter information in the Rake application. You can specify an optional application name to init to allow the Rake software to correctly report the application name when handling a -T command line option.

The second thing we did was change the explicit loop through all the parameters at the end of the script into a single call to top_level. The top_level method not only handles the invocation of the top level tasks, but also is smart enough about the Rake command line options to properly handle them.

One final note about the “gem” command line near the top. The init and top_level methods were introduced in version 0.7.3 of Rake. By using the gem command we can ensure that are using a compatible version of the Rake software.

Summary

When should you use a normal Rakefile, and when should you write a custom Rake application? A Rakefile works best for per-project type of commands, such as those used to build and test your individual projects. You are (almost) always somewhere in the project directory tree when invoking Rake, and so it just does the right thing.

Custom Rake applications work well when the command are not per-project, and you need to run them anywhere in the file system. A custom application gives you the freedom to run the command anywhere and not need a Rakefile first.

Here’s another quick example where I found a custom Rake application to be useful. Lately I have been doing a lot of small Ruby scripts. I have setup TextMate to autorun the tests via rake, but that means before I can test any of my mini-ruby program, I need to take the time to write a Rakefile to run my tests. Normally I would use rake to automate such a repetitive task, but rake isn’t effective until I have a Rakefile, so we’re in a kind of Catch-22 situation. But with a custom Rake application, I can say something like “proj rakefile” ... and have proj do all the heavy lifting for me without writing an explicit Rakefile first.

Ain’t automation grand?

FlexMock 0.6.0 Released   17 Apr 07
[ print link all ]
FlexMock version 0.6.0 was just released over the weekend. You can read the release announcement below for all the new features and enhancements.

FlexMock is a flexible mocking library for use in unit testing and behavior specification in Ruby. Version 0.6.0 introduces a number of API enhancements to make testing with mocks even easier than before.

New in 0.6.0

  • Better integration with Test::Unit (no need to explicitly include FlexMock::TestCase).
  • Integration with RSpec (version 0.9.0 or later of RSpec is required).
  • The flexmock method will now create both regular mocks and partial mocks.
       flexmock()          # => a full mock
       flexmock(person)    # => a partial mock based on person
    

    (flexstub is still included for backwards compatibility).

  • Quick and simple mocks my now be created using an expectation hash. For example:
      flexmock(:foo => 10, :bar => "Hello")
    

    will create a mock with two methods, :foo and :bar,defined. :foo will return 10 when invoked, and :bar will return "Hello".

  • The should_receive method will now allow multiple methods (with the same constraints) be defined in a single call. For example, the following declares that both :read and :write need to be called at least one time each on the mock object.
      flexmock.should_receive(:read, :write).at_least.once
    
  • should_recieve now will allow expectation hashes as arguments. This is similar to the list of methods, but allows each defined method to have its own return value.
      flexmock.should_receive(:name => "John", :age => 32)
    
  • In addition to using a block for defining constrains, constraints may now be applied directly to the return value of new_instances. Combined with the expectation hashes supported by should_receive, simple mocking scenarios have become much more succinct. For example:
        flexmock(Person).new_instances.should_receive(:name => "John", :age => 32)
    
  • Improved implementation, allowing for more flexible use and greater consistency between full mock and partial mocks.
  • Version 0.6.0 also includes a fix for an incompatibility with some older versions of RCov. The FlexMock Rakefile now includes a RCov task (and we have 100% code coverage).

What is FlexMock?

FlexMock is a flexible framework for creating mock object for testing. When running unit tests, it is often desirable to use isolate the objects being tested from the "real world" by having them interact with simplified test objects. Sometimes these test objects simply return values when called, other times they verify that certain methods were called with particular arguments in a particular order.

FlexMock makes creating these test objects easy.

Features

  • Easy integration with both Test::Unit and RSpec. Mocks created with the flexmock method are automatically verified at the end of the test or example.
  • A fluent interface that allows mock behavior to be specified very easily.
  • A "record mode" where an existing implementation can record its interaction with a mock for later validation against a new implementation.
  • Easy mocking of individual methods in existing, non-mock objects.
  • The ability to cause classes to instantiate test instances (instead of real instances) for the duration of a test.

Example

Suppose you had a Dog object that wagged a tail when it was happy. Something like this:

  class Dog
    def initialize(a_tail)
      @tail = a_tail
    end
    def happy
      @tail.wag
    end
  end

To test the Dog class without a real Tail object (perhaps because real Tail objects activate servos in some robotic equipment), you can do something like this:

require ‘test/unit’ require ‘flexmock/test_unit‘

  class TestDog < Test::Unit::TestCase
    def test_dog_wags_tail_when_happy
      tail = flexmock("tail")
      tail.should_receive(:wag).once
      dog = Dog.new(tail)
      dog.happy
    end
  end

FlexMock will automatically verify that the mocked tail object received the message wag exactly one time. If it doesn’t, the test will not pass.

See the FlexMock documentation at flexmock.rubyforge.org for details on specifying arguments and return values on mocked methods, as well as a simple technique for mocking tail objects when the Dog class creates the tail objects directly.

Availability

You can make sure you have the latest version with a quick RubyGems command:

  gem install flexmock    (you may need root/admin privileges)

Otherwise, you can get it from the more traditional places:

Download:rubyforge.org/project/showfiles.php?group_id=170

You will find documentation at: flexmock.rubyforge.org.

— Jim Weirich

 

Formatted: 17-May-08 15:28
Feedback: jim@weirichhouse.org