April 2007
17 posts
1 tag
Jester 1.2: Flexible REST
This release is about making Jester more flexible, and better supporting custom REST APIs. The flurry of activity in ActiveResource is a good reminder that REST isn’t just several default controller actions—it’s a guiding philosophy to defining your own API. REST is just about using simple URLs and HTTP status codes to carry all the metadata, so that the bodies of your requests and responses...
Apr 30th
cats
Matt J. Is there a “how big is my ruby process” method? Matt J. isnt /proc/self/status magical Tammer S. That would make sense. Matt J. Yeah, I think that gives you current process info Tammer S. as long as you don’t drop down to ‘cat’ to read it :) Matt J. right Matt J. then I’d have a bunch of info about cats Matt J. which is nice I guess Matt J. but not...
Apr 27th
1 tag
ActiveResource in a flurry
A look at the Rails Trac’s timeline shows that ActiveResource is undergoing a lot of activity right now, including attention by DHH. Here’s the interesting things I’ve noticed so far: Changeset #6539 – If you save an object, and get an XML body response from the controller, reload the object with the data from that response. So, if the controller performs any machinations on an object while...
Apr 26th
true or false
“We’ll just add a flag in the database.” I hate that phrase, it just sounds like a hack. I’ve seen databases with tables that are nothing but flags. You just know that all through the code are a bunch of ‘if’ statements, conditionally doing all kinds of things on those flags. So a while ago, I decided to pretend databases didn’t support boolean data types. I refused to add any more flags to...
Apr 25th
don't be normal
Database normalization, the database world’s equivalent of DRY, can lead you to write more code than you really need. For example, say we have the following classes: class Group < ActiveRecord::Base belongs_to :group_type end class GroupType < ActiveRecord::Base end And their corresponding tables: groups (id, name, group_type_id) group_types (id, name) In our application, you can...
Apr 24th
cruise_control.rb campfire plugin
We’ve been somewhat unhappy with our current Cerberus installation, so we’ve decided to jump on the CC.rb bandwagon. Though there were a couple of problems when adding projects (I’ll try to expand on that in another post), the overall experience was pretty good—installation was a breeze, and the plugin system makes extending it dead simple. As proof… Campfire plugin for cruise_control.rb A...
Apr 19th
5 tags
Basic Readability
Is this simple code? It’s an example from the docs on Symbol#to_proc: people.select(&:manager?).collect(&:salary) It’s certainly readable. It’s elegant and expressive. But making it possible employs a number of fairly advanced topics relating to automatic conversion of method arguments as well as the ability to extend existing classes—not easy, and not something that someone new to the...
Apr 18th
1 tag
Jester 1.1: Asynchronous REST
Since first releasing Jester, we’ve gotten a fantastic amount of interest and support, and even some donated code. In response, I’ve been whipping Jester into more powerful shape this week. The syntax now even more closely resembles ActiveResource’s and ActiveRecord’s, and adds the ability to use Jester asynchronously. Jester is available from SVN in trunk form, or a 1.1 release form. You can...
Apr 16th
it's all about behavior
How do you know when you need a class? What tells you, “I think I need to create another class”? The answer is: behavior. Not state, behavior. Here’s an example: class Order < ActiveRecord::Base end And our orders table: orders (id, customer, item, price, created_on) That customer column is a varchar that contains the customer’s name. I want to keep it simple, so an Order contains...
Apr 14th
1 tag
My code is great! Look at these numbers!
See, the nasty thing about metrics is that as soon as you start measuring a system, you start changing it. It’s the Heisenberg Uncertainty Principle. Apparently studies have been done that indicate that in successful, maintainable, long lived applications, the average length of methods was 10 lines (I believe this number was derived from Smalltalk applications, but we’re arguing this particular...
Apr 13th
never be satisified
Everyone loves metrics. I think they’re great guidelines and can help you push yourself into writing a lot better code. The first step is knowing the guidelines, then you have to know when to apply them. For example, “classes should have roughly 12-15 methods”; now don’t always follow that for the sake of meeting the metric. In some cases it applies, in others it doesn’t, it’s a judgement...
Apr 13th
unless what
I’m not a huge fan of Ruby’s ‘unless’ keyword. I mean its nice but it can take some while to get used to. For single line ‘unless’ statements like this: puts user.name unless user.name.nil? It’s nice and easy. Here’s how I’d say that in english “Print the user’s name unless the user doesn’t have a name”. Structuring it the other way is not as intuitive to me: unless user.name.nil? puts...
Apr 12th
Unpopular Developer 3: Patterns of Abuse
Kent Beck, along with a hard-hitting one-two punch of a name, has a no-nonsense style and some compelling arguments for the general applicability of the patterns he discusses. As I read, I recognized many of the things I was doing already intuitively, as well as some things that I didn’t. Now, this isn’t a review of Kent Beck’s book; it’s pretty old but far from outdated, and I highly recommend...
Apr 9th
Introducing the Shoulda Testing Plugin
So we’ve been hinting for some time now that we were going to tidy up the testing helpers we use here, and that’s just what we’ve done. Update: Added the Why? section below to address rSpec & Test::Spec Introducing Shoulda! We had a very hard time coming up with a name for this plugin, mostly because of its somewhat eclectic nature. It does three main things: Contexts Shoulda defines...
Apr 6th
I mock your fixtures too.
Mocking is a beautiful thing. There are no words to describe the immense pleasure I get from writing a good mocked test. When I first started writing tests, I had been unexposed to the glory of mocking. The days of relying on fixtures and writing brittle tests are over. Stub and Mock are brothers that live together. Stub knew some things about Mock, and he had a pretty good understanding of...
Apr 4th
1 tag
thoughtbot is hiring...
We’re currently looking to hire a Lead Graphic/UI Designer. We’re looking for someone who has the same level of passion and desire web application user interfaces and for elegance about the markup that drives an interface that we do about our back end code. We’d love to find someone to work in our Cambridge, MA office with the rest of the team (or in NYC in our ‘satellite office’), but we are...
Apr 4th
6 tags
Jester: JavaScriptian REST
Jester is our implementation of REST, in JavaScript. It provides (nearly) identical syntax to ActiveResource for using REST to find, update, and create data, but from the client side. Update, 6/16/07: We have released version 1.3 of Jester. You may want to view its release description. Jester is available from SVN in trunk form, or a 1.1 release form. You can also download a zipped copy of...
Apr 2nd