Ruby Hoedown!
Posted on August 12, 2008
by Tommy McGuire
Friday, 9:00am Ruby: A Year of Innovation by Jason Seifer and GreggPollack.
I got here a little late, and so may have missed part of the
presentation, which seemed mostly to be a long list of interesting
projects:
- Phusion Passenger: Apache module-served Rails (actually, Rack)
applications. - Github: source management + FaceBook. The specific neatness was the
ability to get a fork off a project, make changes, and then have the
upstream maintainer *know* that you have made those changes and
possibly merge them back into the upstream branch. - EventMachine: a single-threaded, event driven server framework,
somewhat similar to Twisted. Examples using EventMachine were
Evented Mongrel, Merb (allowing the use of event driven handling for
short tasks and threaded handling for longer ones), and Thin (which
is EventMachine + Rack + Mongrel's URL Parsing). - Starling (http://rubyforge.org/projects/starling/): a lightweight,
persistent, reliable distributed message queue. - Redmine (http://www.redmine.org/): a project management web
application. - Pool Party (poolpartyrb.com): balance, monitor, and maintain Amazon
EC2 cloud computing configurations. - Rad (rad.rubyforge.org): an Arduino development platform for Ruby.
- Adhearsion (adhearsion.com): integrating and controlling VOIP
applications based on the Asterisk software PBX. - make_resourceful (http://mr.hamptoncatlin.com/): a RESTful DRY
(don't repeat yourself) helper for Rails controllers. - Hpricot (http://code.whytheluckystiff.net/hpricot/): a HTML parser.
- Juggernaut (juggernaut.rubyforge.org): a Rails plugin that enables
the server to push data to the client. - Ambition (ambition.rubyforge.org): an SQL generator (and general
query language) generator using Ruby syntax. - Prawn: a pure-Ruby library to generate PDF files.
- Capistrano: the server deployment tool.
- Various Ruby VMs: all are demonstrating innovation and progress.
- IronRuby
- JRuby
- Gemstone
- Maglev
- The Roo gem: parsing Google Docs, Excel, and OpenOffice spreadsheets.
- The Ruby DTrace provider: probes into a live Ruby process.
- Skynet: a Ruby implementation of Google's mapreduce.
- Data Fabric: scale ActiveRecord databases horizontally.
- Merb: a lightweight web framework.
- Mack Framework: a distributed web application framework for
portal-like applications. - Sinatra: a web framework for RESTful applications
- Webby: a framework for offline generation of non-dynamic web sites.
- Two from why: Shoes, a small graphical toolkit, and Hackety Hack, a
site for teaching Ruby hackery to kids.
See railsenvy.com/hoedown (and railsenvy.com/podcast).
Friday 10:30 Cloud Computing with Ruby by Robert Dempsey.
Robert brought the message that Rails CAN scale, at both the web
service and database level, if you know how. Scalability, in this
case, means not only that the system can handle large amounts of work
but also that it can be enlarged to grow as demand increases. Cloud
computing provides that ability. Cloud computing, as defined by
Robert, requires:
- The ability to purchase capacity easily and immediately,
- no need to get involved in purchasing or owning hardware,
- an API for programmatically controlling the configuration, and
- that the whole process take no more than 10 minutes.
A standard production deployment, according to Robert, is two load
balancers, two web servers, and two databases; this runs in the
vicinity of $432 per month.
The options Robert discussed include:
- Amazon Web Services (EC2 and S3), the base of most of the other
offerings. - Morph, which provides no ssh or file-level access.
- RightScale and RightGrid.
- Heroku, which is free (for now).
- Joyent Accelerator, which is a VPS, not really cloud computing and
involves OpenSolaris. - Vertebra.
- PoolParty, which is a Ruby gem plus AWS and which was not ready for
production. - Scalr, which is also free code built on AWS.
- ElasticRails, free for non-commercial use.
For recommendations, Robert first suggested deciding whether you are a
sysadmin or a developer; if the latter, then to go with Morph, Scalr,
or RightScale.
For more information, see Programming Amazon Web Services, REST on
Rails 2 Projects, and an AWS article series, Introduction to AWS for
Ruby Developers.
Friday, 1:00pm Mock Dialogue, Joe O'Brien and Jim Weirich
Joe and Jim gave a cute skit on the topic of mock objects and
testing.
Using mock objects (as any testing) requires require the code to be
written specifically to allow the use of the mocks. Using mocks,
however, goes further to allow tests to (in Michael Feather's rules),
- Not talk to the database,
- Not use the network,
- Not use the filesystem,
- Run at any time, and
- Not require anything special in order to run.
Mock objects are an extension of testing fixtures such as
hand-generated stubs. Hand generated fake classes, for example, can
become as complex as the code being tested, and remedying that can
lead to a large number of testing classes. Mock objects
- on the one hand, help clean up that situation by making the creation
of test-specific stubs as simple as possible, while - on the other, allow the behavior of the code under test to be
validated by ensuring the mock object's methods are called the
correct number of times and with the correct arguments.
Just be sure not to go so crazy with mocks that you don't actually
test anything.
P.S. Ugly, difficult tests may indicate bad application code.
P.P.S. The presenters like Flexmock.
Friday, 2:15pm Ruby Best Practice Patterns by Rein Henrichs.
Rein gave a somewhat humorous song and dance about how best practices
are bad on job security grounds....
Rein described best practices as the set of techniques that experts
*currently* recognize and use, and patterns as the decisions experts
make over and over. All are learnable and optimized to communicate
effectively.
The patterns Rein identified in Ruby are:
- Composed method: How to divide a class into methods. Each method
should perform one task, and have a good name. Any complex method
should be composed from simpler methods, to allow each method to be
understood in a single gulp. - Execute around method: Ruby methods can accept blocks! The method
executes before and after yielding to the block. - Yield and return: yield the subject of the method to the block, then
return the object. [Ok, this one needs further study.] - Method object: Have many lines of code sharing the same parameters
and temporaries? Replace the state threaded through the lines with
a state object which has the code as its methods.
The best way of discovering patterns is to read expert's code. Also
read Smalltalk Best Practice Patterns by Kent Beck.
Friday 4:00pm Lightening talks
- God and its forthcoming web interface. See github / pjdavis.
- Bryan Liles - Testing for normal people who say, "Test all the
fucking time."
- Think of your application as objects expressing behavior and
create examples of those behaviors. - test/spec
- bacon
- shoulda
- mspec
- Test::Unit + shoulda + RSpec + StoryRunner
- Cucumber?
- Think of your application as objects expressing behavior and
- Youssef Mendelssohn - What is Truth? In Ruby?
- nil and false are not.
- github.com/ymendel/truthy
- nil and false are not.
- Google charts is cool, especially with the google_chart gem.
Friday 5:00pm Keynotes by Obie Fernandez and Chris Wanstrath
First, Obie Fernandez:
- Do great work for a few years.
- Write a book.
- Consult.
- Profit.
- Never Eat Alone
- Secrets of Power Negotiating
- Predictably Irrational
- Purple Cow
- Hirise lead tracking software
Then, Chris Wanstrath gave an inspiring keynote essay, which should be online someplace.
Saturday 9:00am Calling Your Code: Gluing Phone Calls to Ruby by Troy
Davis.
Demos:
- Twittervox: Listen to the Mars Phoenix Lander twitter feed by phone.
- Yelpvox: Find good, nearby restaurants by phone, using the phone
number of a bad, nearby restaurant. - SendSign: Get real estate flyer information by phone and MLS number;
also use a web interface to see record of phone queries.
Twittervox is implemented using Cloudvox and a slice from SliceHost.
- Swift text-to-voice engine
- Adhearsion (or Telegraph and RAGI)
- Asterisk
- FreeSWITCH
Tips for building voice apps:
- "Can you hear me now?" is not testing.
- If you have to call, you are not testing.
- Use a paper prototype first.
- Get the core functionality: small first.
- Placeholders first.
- Text-to-speach is a good placeholder.
Saturday 10:15am Ruleby: The Rule Engine for Ruby by Joe Kutner.
Joe began with where declarative programming and rule engines fit into
the programming language landscape. He described a rule engine-based
system as made of a set of facts, a set of rules, and the Rete-based
rule engine. The separation of rules and facts centralizes business
logic knowledge.
In Ruleby, facts are Ruby objects; they become facts by being asserted
and can be retracted. The rules engine can fit effectively into Rails
applications between the controller and ActiveRecord.
Saturday 1:15pm flog << Test.new
Working with an existing codebase is significantly different from
writing new code. One piece of advice: build a scaffold of tests
before starting to change the existing code.
- Survey the code: Do not get distracted by incomprehensible code.
- Put the commandline script under test.
- Some code is resistant to testing: make the smallest change to
make it testable. - Some code is mysteriously coupled to other code: leave pending
markers to indicate the mystery.
- Some code is resistant to testing: make the smallest change to
- Put the library entry points under test.
- "Characterization" tests - "This code does A."
- Use CURRENTLY to mark things that may be wrong.
- Recursive code?
- If faced with a "Big blob of code": carefully
pull things apart. - Small commits are good, particularly for reverting.
- At one point, he broke flog, but all of the tests pass, so he
decided to add integration tests to act as stronger scaffolding.
- If faced with a "Big blob of code": carefully
- Pin down behavior with integration tests. (Should have done this
first.)- One trick: use a YAML dump to record internal behavior of
original. - Use code coverage to identify parts which are not tested...and to
- Depending heavily on attributes makes code hard to test.
- One trick: use a YAML dump to record internal behavior of
I unfortunately missed the second set of lightening talks, as well as Saturday's keynote.
[Edit: Obie Fernandez is actually named "Fernandez". Sorry! Great book, by the way!]
Comments
My name is Obie Fernandez (with an 'F')... thanks for the great notes of the conference.Obie
2008-08-12