Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: December 2008

Pivotal Labs

Standup 12/8/2008

Pivotal Labs
Monday, December 8, 2008

Old Version Woes

At standup today, it’s been reported that Hpricot 0.6.161 doesn’t work on our Windows VM sandbox setup, while the newest version: 0.6.164, is just peachy. So watch for this and perhaps get to upgradin’.

Likewise a bug in Rake 0.8.3 breaks our CI behavior, but is apparently solved in the 0.8.4 release candidate, a.k.a. 0.8.3.99, which can be found on Jim Weirich’s github.

So that’s it for now. This is one of the hazards and boons of the world of fast-moving open-source projects. Bugs happen, as in all software, but they seem to be solved quickly, or else there’s always room for you to dig in. So be aware and look out for the next version!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Apply writing advice to code

Pivotal Labs
Saturday, December 6, 2008

Writing good code and writing good English are a strikingly similar endeavors. We should be able to apply writing advice to code – not perfectly, but on the whole.

These are some of my favorites – I welcome more thoughts and citations in the comments:

  • Never use a metaphor, simile, or other figure of speech which you are used to seeing in print.
  • Never use a long word where a short one will do.
  • If it is possible to cut a word out, always cut it out.
  • Never use the passive where you can use the active.
  • Never use a foreign phrase, a scientific word, or a jargon word if you can think of an everyday English equivalent.
  • Break any of these rules sooner than say anything outright barbarous.

…

A scrupulous writer in every sentence that he writes will ask himself at least four questions, thus: What am I trying to say? What words will express it? What image or idiom will make it clearer? Is this image fresh enough to have an effect? And he will probably as himself two more: Could I put it more shortly? Have I said anything that is avoidably ugly?

Orwell, “Politics and the English Language” (a brilliant essay)


To write a genuine, familiar, or truly English style is to write as anyone would speak in common conversation and who had a thorough command or choice of words or who could discourse with ease, force, and perspicuity setting aside all pedantic and oratorical flourishes.

William Hazlitt


As a general rule, run your pen through every other word you have written, you have no idea what vigor it will give to your style

Sydney Smith


Clarity of writing usually follows clarity of thought. So think what you want to say, then say it as simply as possible.

…

(Selected do’s and do-not’s, summarized)

  • Do not be stuffy. Use the language of everyday speech, not that of spokesmen or bureaucrats. Consider rephrasing sentences more pithily and accurately. Avoid, where possible, euphemisms and circumlocutions promoted by interest groups.
  • Do not be too pleased with yourself (perhaps akin to Kill Your Darlings)
  • Do your best to be lucid. Simple sentences help. Keep complicated constructions and gimmicks to a minimum.

…

Scrupulous writers will also notice that their copy is edited only lightly and is likely to be used. It may even be read.

from The Economist Style Guide

More resources:

  • Eric Evans’ emphasis on Ubiquitous Language in Domain-Driven Design (book, website, wikipedia) is in the same spirit.

  • Style guides for writers and journalists are good resources, examples are the Economist Style Guide (online, book) quoted from above, and the Chicago Manual of Style (online, book).

  • Steven Pinker’s The Language Instinct is a great starting point for exploring the connection between cognition and language.

  • Chapter 17 of Zen and the Art of Motorcycle Maintenance, which merits its own post…

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Davis W. Frank

Standup 12/5/2008: RubyMine gets Focused; We're slow & lazy

Davis W. Frank
Friday, December 5, 2008

Interesting Things

  • A polite reminder that when defining associations that need :class_name or :source keys that the values should be strings and not Ruby constants. That way lies madness.
  • RubyMine build 500 gets running “Focused” Test::Unit tests (file or single test) right via Ctrl-Shift-F10. Specs aren’t working quite right yet, but JetBrains appears to be working on it.

Ask for Help

“Anyone having odd slowness with Google Gears?”

We are having an issue with slowness in a Google Gears app, where certain actions take several times longer on some boxes. It is only slow on some of the client’s windows XP machines, but not all. Never on mac. It is slow in BOTH Firefox 3 and IE 7 on the slow machines.

The Gears sqlite db and dir does not seem to be the problem either – a clean IE data, cache and gears data dir still runs slow, and moving the ‘slow’ gears data dir to a fast machine runs fast.

Also cleared all IE data, compared/upgraded Gears versions, Java versions, and Windows Service Pack versions. Nothing seems to be a common denominator yet. Nothing obvious on google searches…

“Multi-select widget for a ‘has_many :through’ relationship?”

I have an association like this:

class Foo
  has_many :bars, :through => :barrings
end

I’m looking for a ‘widget’ for the Foos page that will let me assign/unassign multiple Bars at once. Looking at the select, select_tag, options_for_select helpers, etc, reminded me that the Rails built-in stuff is lacking. I was hoping that someone has already written a sweet multi-select widget that I could be lazy and use.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Dan Podsedly

GitHub post receive hook for Tracker

Dan Podsedly
Thursday, December 4, 2008

Chris Bailey wrote a GitHub post receive hook for Tracker, using the API. It’s a web service that you run on your own server, and it automatically updates stories in your project(s) based on commit comments. Check out his blog post here. Thanks for spending your Thanksgiving on this, Chris.

Let us know if you find this useful, we’re definitely interested in making integration with other apps easier, and would love specific ideas and suggestions.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
David Goudreau

Standup 12/03/2008: Instance variables in Selenium

David Goudreau
Wednesday, December 3, 2008

Help!

  • Instance variables in Selenium? We’re setting up a User model instance in a setup method. We want to use that User instance in our test, naturally. But when we get into the test, the User instance has no methods on it. It’s a standard Test::Unit Selenium test. Any ideas?
  • hoe/rake/rspec dependencies and CI? The following combination will break CI. The issue is that RSpec 1.1.11 depends on Hoe 1.8.2 and Hoe 1.8.2 requires Rake 0.8.3, which will break our CI environment. RubyGems may also need to get upgraded to get this combination to work. Sounds like a bit of work…
  • Uploaded file encodings? We’re getting truncated content when uploading files encoded with ISO-8859-1 Windows. Any ideas why this is happening? Can we check the encoding when the file is uploaded?
  • Clock.now with a time zone in a named scope in the TEST Rails environment does not use the MockClock class (which lets us manipulate time in our tests). Why isn’t it being used?
  • Demo environment DNS propagation & Apache configuration. The expected demo URL isn’t working. It sounds like Ops just recently set the name in DNS so it’s probably still getting propagated around.

Interesting Things

  • Apparently Treetop does not let you assume equality in the usual Ruby ways. Just something to look out for.
  • Last night we hosted a panel in conjunction with our partners Venture Archetypes called Project Startup. It’s a regular panel we’ve been hosting for a while now. It happens roughly every 2 months.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Adam Milligan

ActiveRecord learns to respect your privates

Adam Milligan
Tuesday, December 2, 2008

This is somewhat old news, but I don’t think it has received the attention it deserves. As of Rails 2.2, ActiveRecord associations and attributes will now behave properly with regard to access control. You can view the Rails tickets, with patches, here and here.

Take, for example, this schema:

mysql> desc accounts;
+----------------+--------------+------+-----+---------+----------------+
| Field          | Type         | Null | Key | Default | Extra          |
+----------------+--------------+------+-----+---------+----------------+
| id             | int(11)      | NO   | PRI | NULL    | auto_increment |
| balance        | int(11)      | NO   |     | 0       |                |
+----------------+--------------+------+-----+---------+----------------+

used by this model:

class Account < ActiveRecord::Base
  def deposit(amount)
    do_state_and_federally_mandated_things
    balance += amount
  end

  def withdraw(amount)
    if sufficient_funds?(amount)
      do_state_and_federally_mandated_things
      balance -= amount
    end
  end

private :balance=

private

  def do_state_and_federally_mandated_things
    ...
  end
end

You most likely don’t want someone coming along and modifying the balance attribute directly, either intentionally or inadvertently. However, prior to Rails 2.2, ActiveRecord ignores the privacy declaration for #balance=, so you must execute horrid machinations in order to protect it:

class Account < ActiveRecord::Base
  def balance=(amount)
    raise "I'm private!"
  end

  def deposit(amount)
    do_state_and_federally_mandated_things
    write_attribute(:balance, balance + amount)
  end

  ...

As of Rails 2.2, ActiveRecord will respect private accessors for database column attributes.

Along the same vein, if we add the following:

class User < ActiveRecord::Base
  has_one :account
end

Now we can call methods on the proxy returned by calling User#account, just as if we were calling methods on an account instance; any methods:

johnny_taxpayer = User.first
johnny_taxpayer.account.withdraw(700_000_000_000)
johnny_taxpayer.account.do_state_and_federally_mandated_things

Who knows what scary things #do_state_and_federally_mandated_things does? This will, frighteningly, run just fine prior to Rails 2.2. But, no more.

Now, a number of people have considered this change and asked “why bother?” Ruby allows access to private methods via #send, so they’re not really private, right?

This argument leads down the dark path. Like it or not, cheat around it as you may, access control is an important aspect of object oriented programming. If nothing else, the private keyword is my way of saying “hic sunt dracones,” or “hands off!” It’s also a way of saying “this method may or may not exist in the future.” As a class designer I have every right to refactor that private method entirely away, thus breaking any code that calls it; including, significantly, test code.

More fundamentally, object interactions should be via interfaces. If code makes calls to an object’s private methods, that code has now tied itself to the object’s implementation. Coupling ensues, duck-typing breaks down, anarchy reigns.

So, this begs the question, why does #send ignore access control?. Why should two forms of sending a message to an object differ in their access control semantics? Sometimes I’m forced to use #send:

method_name = extract_method_name_from_the_aether
some_object.send(method_name)

In order to make this code correct with regard to access control I have to add cruft:

method_name = extract_method_name_from_the_aether
some_object.send(method_name) if some_object.respond_to?(method_name)

Now, this is not to say that I don’t think Ruby should provide the ability to call private methods, or generally dig around in an object’s internals. This comes in handy in some instances (although I find many of these instances are short-term solutions that should get refactored away). But, in an ideal world I think the sender should explicitly specify when a message should ignore access control:

potentially_private = extract_method_name_from_the_aether
some_object.send_without_restriction(potentially_private)

This makes the syntax somewhat more ugly, but ugly syntax suits an ugly operation.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
David Goudreau

Standup 12/01/2008: Fun with libxml

David Goudreau
Monday, December 1, 2008

Interesting Things

  • Libxml has been giving us some more strange behavior on Linux. If you do
parser = XML::Parser.new
parser.string = '<foo></foo>'
document = parser.parse

# Now watch me fail, but only on Linux!
parser.string = '<bar></bar>'
document = parser.parse
  • We’re hosting a MagLev tech talk today compliments of Martin McClure.

  • Joseph Palermo has won the annual Pivotal Labs Mustache Competition. Granted, he was the only entry. But don’t let that affect your admiration of his work. Photo to follow.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (783)
  • rails (117)
  • testing (90)
  • ruby (86)
  • ruby on rails (71)
  • jobs (62)
  • javascript (59)
  • techtalk (44)
  • ironblogger (42)
  • rspec (39)
  • bloggerdome (34)
  • productivity (34)
  • activerecord (30)
  • rubymine (30)
  • git (29)
  • gogaruco (29)
  • nyc (27)
  • design (24)
  • mobile (23)
  • pivotal tracker (22)
  • process (21)
  • cucumber (21)
  • jasmine (19)
  • ios (18)
  • tracker ecosystem (17)
  • webos (17)
  • objective-c (17)
  • fun (16)
  • android (16)
  • palm (16)
  • ci (16)
  • "soft" ware (16)
  • bdd (15)
  • tdd (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • css (14)
  • gem (13)
  • mouse-free development (12)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • api (12)
  • keyboard (11)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
Subscribe to Community Feed
  1. ←
  2. 1
  3. 2
  4. 3
  5. 4
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >