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: May 2007

Extra Action

Alex Chaffee
Saturday, May 19, 2007

It was fate. A crew of Pivots in Portland on the same weekend as the Extra Action Marching Band We just had to seize the opportunity…

Will they be making an appearance at our Beer Night tonight? You never know…

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 05/17/2007

Joe Moore
Thursday, May 17, 2007

Interesting Things

  • Yahoo’s Geolocation service is broken after they released a new version if their code. Zip code searching in particular significantly broken — discussion thread here: http://tech.groups.yahoo.com/group/yws-maps/message/5468 — here is an example:
    • Search for a zip code using the following URL: http://local.yahooapis.com/MapsService/V1/geocode?appid=YahooDemo&location=94102
    • Result (notice the bad State and Zip tags):
<code>
    <?xml version="1.0"?>
    <ResultSet xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps"
               xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">
      <Result precision="zip">
        <Latitude>37.779411
        <Longitude>-122.417740
        <Address>
        <City>San Francisco, CA 94102
        <State>United States
        <Zip>
        <Country>US
      </Result>
    </ResultSet>
        <!-- ws05.search.re2.yahoo.com compressed/chunked Thu May 17 15:02:00 PDT 2007 -->
</code>

UPDATE
This is fixed! Thanks, Yahoo!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Edward Hieatt

Taming JavaScript

Edward Hieatt
Thursday, May 17, 2007

The explosion of client-side JavaScript in Web 2.0 applications has taken many developers by surprise. I’ve often found that more senior members on web development teams shy away from JavaScript coding, preferring the known quantity (and perceived purity) of server-side development. After all, isn’t JavaScript that flaky, inconsequential language that we used to use to make pretty pull-down menus, but that can’t be relied on for any serious purpose? Since when did it become something that I can’t leave to my UI designer? Can’t I just Google for a script kiddy’s website any more? Do I really have to start taking JavaScript seriously? Well, yes. These days, it’s becoming inevitable that the majority of the team comes into contact with client-side JavaScript. But still some of us resist it, largely due to painful past experiences of long nights spent trying to get browser X to work the same as browser Y.

As a consequence, I consistently observe two patterns over the course of a project. First, the client-side effort doesn’t get the benefits of the skill and experience held by seasoned object-oriented developers. Instead the JavaScript code is left to newer, less experienced members of the team; the rigorous practices that the more senior members of the team usually insist on aren’t advocated for to the same degree on the client side. Second, because of the fear of JavaScript, opportunities to make the application slicker, more user-friendly and generally more modern are missed.

I don’t mean to downplay the difficulty of JavaScript coding. There’s no doubt about it: it’s eccentric, it’s not consistent between browsers, it’s slow where you don’t expect it, it does objects in a weird way, and the list goes on. But here’s where we can turn the situation on its head. What does our experience tell us about how to attack a difficult area in our code? It certainly doesn’t tell us to ignore it and hope it works out in the end. No, it tells us to shine a light on the painful area and apply our development practices even more strictly than usual: test-drive it, cover it with unit and functional tests, aggressively refactor it, separate concerns, extract the right objects, apply design patterns where they can help, and so on.

What I’ve seen work when it comes to JavaScript is to fight fire with fire. Rather than responding to the difficulties of JavaScript by shying away from it and rationalizing a lack of quality in our client-side code, we can choose to react by applying our practices more strictly, not less. We can ask ourselves how to better test their JavaScript, how to expose complexity more clearly, how to objectify concepts more naturally. We can break our JavaScript into layers, and apply typical MVC patterns as we might do in server-side Java or Ruby on Rails code. We can abstract our AJAX requests and responses in order to better simulate them in our tests. We can run our tests in a continuous build on all our target browser/platform combinations. Why not try to hold our JavaScript to the same standards as any other part of our code? It’s not always easy, and it certainly takes practice and strict discipline. I’ve found that the learning curve is steeper and longer than with other languages. But I’ve also found that there’s really no reason why we can’t be as rigorous with our client-side development as we are anywhere else in our codebase as. We end up with all the usual benefits: better stability, fewer bugs, more malleability.

Getting started

Amongst other topics, over the next few weeks I’ll be posting concrete ideas for ways to approach JavaScript development. Most of them will center around JsUnit, because in my experience it’s the introduction of unit tests and test-driving that drive the most dramatic improvements in not only the software but how we think about our work.

So, what does it look like when a team attacks JavaScript in this way? As someone who has been through his fair share of pain coding JavaScript, it’s thrilling to observe. I’ve seen teams at Pivotal Labs take a more disciplined and rigorous approach to JavaScript than I could have imagined even a couple of years ago. And the best part is that besides the benefits I already mentioned, there’s a huge payoff to all this added discipline: rather than being afraid of JavaScript development, we sometimes enjoy it and look forward to it. It’s simple, really: JavaScript is hard, so let’s throw everything we know at the problem. I’ve found that if we do, we can tame JavaScript to the point where our progress becomes as predictable as we expect in the rest of the codebase.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Christian Sepulveda

Client Launch: Bring Light

Christian Sepulveda
Wednesday, May 16, 2007

Congratulations to Bring Light! They recently launched and we want to thank
Drew of Bring Light, Ruby Red Labs and all the Pivots who worked hard to make
it a successful launch.

Bring Light connects charities with the communities that support them.
Effective philanthropy really benefits from collective action and Bring Light
hopes to leverage the Internet to match the passion, commitment and interests
of individuals with worthwhile causes.

Pivotal Labs has been privileged to help Bring Light make a difference.

Alex adds:

And kudos on a killer article in the SJ Mercury News! (Cute picture too!)

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 05/16/2007

Joe Moore
Wednesday, May 16, 2007

Interesting Things

  • We’ve set up a Pivotal Rubyforge Project! Keep an eye out for code from us.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Using JSON on the request with Ajax.Request postBody

Pivotal Labs
Wednesday, May 16, 2007

This is nice in a heavy Ajax application – you can use the same data format on the request and the response.

You might not have been aware that prototype’sprototype’s Ajax.Request can send a postBody, instead of parameters.

So if you don’t mind all of your Ajax requests being POSTs (I don’t), you can just ignore serializing parameters and just stick JSON in the postBody.

This makes my jsunit tests (and therefore my production code) nicer:

BEFORE:

<code>
function testRequest() {
  var settings = {volume:"high", color:"red"}

  var command = new SaveSettings(settings);

  assertEquals("/save_settings", command.asAjaxPayload().url);
  assertEquals("volume=high&color=red", command.asAjaxPayload().parameters);
}
</code>

AFTER:

<code>
function testRequest() {
  var settings = {volume:"high", color:"red"}

  var command = new SaveSettings(settings);

  assertEquals("/save_settings", command.asAjaxPayload().url);
  assertEquals(settings, JSON.parse(command.asAjaxPayload().postBody));
}
</code>

(and of course, you can push the stringifying of the post body down a layer, to get rid of the JSON.parse at this level)

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 05/15/2007

Joe Moore
Tuesday, May 15, 2007

Ask for Help

  • “Does anyone have recommendations for browser-embedded WSIWIG text editors?” The #1 recommendation is TinyMCE, followed by FKEditor
  • “Rails cached-pages sweepers are causing a nil.controller_name_ error deep in the rails framework…” We ‘fixed’ this with a variation of this patch: http://dev.rubyonrails.org/ticket/6199
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 05/10/2007

Joe Moore
Thursday, May 10, 2007

Interesting Things

  • Several folks here are looking at Merb (Mongrel with ERB) as a light-weight alternative to Rails for certain targeted usages. We’ll be sure and attend the Merb hack-fest at Rails Conf.
  • Debian MySQL pain: if your MySQL Client and Server versions do not match, MySQL behave badly, reporting that it cannot find UTF-8 support.

Ask for Help

  • “Can you terminate an AJAX request?” The answer is “kinda”. XMLHttpRequest has an abort() method will terminates the request in the browser and prevents any callbacks from being invoked. But, your server might still be chugging away on the requested action.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 05/09/2007

Joe Moore
Wednesday, May 9, 2007

Interesting Things

  • Hpricot versions 0.4 and 0.5.x are causing us Segmentation faults. Why, Why?
  • Rails gotcha: Rails’ automatically generated finder methods will not work properly if you have a class name with the word ‘And’ in it. For example, a RentalCarCompany might have many CarsAndTruck. You will have problems if you try to call RentalCarCompany.find_by_cars_and_truck_ids because the _and_ is reserved for methods such as find_by_name_and_address.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 05/08/2007

Joe Moore
Tuesday, May 8, 2007

Interesting Things

If you are missing the Rspec gem, you specs will fail silently. It’s a good way waste a few hours trying to figure out what’s wrong.

  • 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. →
  • 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 >