slammin’ extensions

One of the cooler things about Ruby is the way you can extend objects with methods for a specific case. It really makes you feel like you’re slinging code, rather than just organising objects. Rails makes really good use of this ability with Association extensions.

Association extensions allow you to do cool things like:

class Person < ActiveRecord::Base
  
  has_many :messages do
    
    def mark_as_read!
      find(:all).read!
    end
    
  end
  
end

So now you can set all the messages for a particular person as “read” by calling:

oliver.messages.mark_as_read!

Cool, huh? (There’s more in the documentation if you’re interested).

A common antipattern I see is something like the following:

oliver.add_message!( new_message )

Being called to add a new message onto a Person’s “messages” association, when you’ve got some extra logic in add_message! which the default ActiveRecord “<<" method doesn't do for you. For example, you might need to send an email to notify the user they've got new messages.

Hey man, don’t forget the slam operator!

a = []
a << 1 << 2 << 3
puts a
#=> [1, 2, 3]

Well, I call it the “slam” operator, but it’s more correctly called the “push” operator. Or the bitwise left shift, depending on what kind of object you’re calling it on. Slam sounds way cooler though.

You can use the slam operator for your association extensions like this:

class Person < ActiveRecord::Base
  
  has_many :messages do
    
    def << new_message
      returning proxy_owner.messages do |m|
        m.add_message!(new_message)
      end
    end
    
  end
  
end

oliver.messages << a_brand_new_message

Super cool! You could also move the add_message! logic inside that extension, or make it private - force everyone to use the slam!

(PS. “proxy_owner” refers to the owner of the association - in this example, “oliver”. We use that “returning” block so that the << method returns the proxy_owner's messages collection and behaves like the same method on Array. It also means we can chain slams! CH-CH-CHAIN SLAM!)

(PPS. Don’t forget Assocation Callbacks - like :after_add or :before_add - for simple cases :) Don’t get complex unless you’ve got to!)


the pinky-blue house

It’s a sentence. Well, it’s more of a word in reality. It usually comes right at the end of a long list of desired functionality.

And it’s the bane of every developer (and I dare say a good number of BA’s too).

It goes like this:

We want “eTunes” to show the user a catalogue of music, allow them to download it and us to bill their credit cards for it, and if possible we’d also like to show the user some music we’ve picked based on what they’ve bought before. Oh, and we want it to be flexible.

In my experience that last sentence basically means “If we change our mind at any point it should be really easy for you to make our changes”.

Let me translate that into architect-speak for you. We’ve built your house, three stories, five bedrooms, double-glazed windows, everything you’ve asked for. We’ve even painted it that lovely shade of baby blue you asked for a couple of months ago.

But looking at it now, it just blends in with the sky a little too much. It’s not making the statement you were looking for. So you want to repaint it. Pink.

Sweet! That’s fine. We’re architects, we know all about people changing their minds. After all, you have to live in it. So we repaint it, and give you the bill for the painting. And then you say hang on just a gosh-darned minute! I said I wanted the house colouring to be flexible on the original drawings!

You see the problem. We’ve still painted it. We still need to pay for the paint and the painters. It doesn’t matter at all whether it was blue, green, or purple with black polka dots before we painted it. And now we’ve done what you’ve asked.

Now, don’t take this the wrong way. We’re all about flexibility. In fact, it’s our middle name (Code to Flexible Customer makes it sound like we’ll only write code for you if you can do a Full One Legged King Pigeon). That’s why we make sure we’re in constant communication with all our customers.

We know, stuff changes. You see your shiny new site there and another bright idea hits you, or you do some user testing and no-one can spot the “buy” button. That’s great - that’s why you chose us, and you chose Rails. Because we can make those changes - and we can make ‘em fast.

But please, don’t assume that just because you said “flexible” three months ago, suddenly any change is trivial.

Okay, rant over.


design vs. usability

Saw an interesting example of the power of affordances the other day.

We were visiting a (hopefully soon-to-be) customer at their offices. Awesome offices - top floor, goldfish tanks, plenty of sun. The elevators are decorated in this kick-ass cold war pseudo-james-bond style. Fittingly, the “down” elevator button is a giant red push button that looks as if it is capable of launching a nuclear missile. Escape Hatch-styled lift.

The issue here is obvious. People are hard-wired to think about “alarms” or “fire” or “really embarrassing occurrences” connected with a button like that. So, the tenants in this building needed to tack a second sign to the lift button (somewhat spoiling the “escape hatch” effect) to reassure people that they won’t be followed out of the building by flashing lights and klaxons…


on identity

“If you wake up at a different time, in a different place, could you wake up as a different person?”

— Chuck Palahniuk

Oliver Kickboxing
A few things recently have been causing me to consider the somewhat nebulous concept of “identity”.

I’m not going to ruminate over our “Ikea lives” (I’ll leave that to the much better qualified author of Fight Club), but a subject rather closer to home - our business.

Who (or rather what) is Code to Customer?

Last night I had to deliver a speech for the Summer of Code. The brief was to “tell us a little about your business”. Well, there’s the obvious - we’re a two-person Ruby on Rails shop who kick ass and chew bubblegum. We write beautiful Rails code - that’s what we do and what we love to do.

I feel like there’s more though. So I present to you, loyal reader and patient digester of my ramblings, Who We Are (unabridged).

  • We have Customers. Not Clients. There are two types of people who have Clients. The first being Lawyers. I’ll let you guess at the second.
  • We help our Customers kick ass. It’s no fun being a silent partner - if there’s something we think you could do better, we’ll let you know. We’re also prepared to put in the hard yards when necessary. Case in point - I’ve been up all hours of the night for the past week helping the awesome guys at Wildfire get their app ready for a big launch.
  • It’s as important to be honest as it is to be nice. Sadly, they are occasionally mutually exclusive
  • We’re a business, not a “start-up”. And we make no apologies for that. We think it’s just as important to have businesses in this world which are in the black every single month as it is to have the start-ups who are taking the all or nothing “i’ve-maxed-out-my-credit-cards-what’s-next” leap. And we have no time for people who tell us that means we’re taking the “easy way out”.
  • There’s more to us than just code. Sure, Oliver and I live, eat, sleep and breathe Ruby when necessary. But we make sure there is balance - time out from behind a display. Ollie does kickboxing (see illustrative photo above), and I rock out with my band every so often.
  • If you’re going to spend your time on something, you better be doing it right. And you better be having fun at the same time.
  • Money’s not the game, but it is a pretty good way to keep score.

Another catalyst for this introspection was my serious business card drought. How the heck am I meant to feel like a legitimate businessman without my little identity cards?

So we’ve charged the epically talented and always awesome James Nisbet with coming up with a new logo for us. He’s doing awesomely, especially since our typical feedback runs along the lines of “Umm, well, I kinda like that but, uhh… maybe…. more blue?”.

Here’s what we’ve got so far:

Code to Customer Logo Concept

What do you guys think? Maybe someone can give James some coherent feedback. I sure can’t.


motivation

When its a hard day at work, and nothing seems to be going right, sometimes the best thing is just a cold drink. Even a Milkybar would be nice!

At Code to Customer, we embrace this philosophy.


This is after a pretty hard walk back from MoreWilsons carrying ~16kg each in awkward shaped boxes. But totally worth it.

The above image is something potential Summer of Code students should keep in mind ;)


viagra online | buy viagra online | buy viagra order| buy viagra now | buy viagra pills | prices viagra | viagra mexico | viagra pharmacy | viagra price viagra online, order viagra Online, buy viagra order - online medical center (we take care of you)cialis online | buy cialis online | buy cialis order| buy cialis now | buy cialis pills | prices cialis | cialis mexico | cialis pharmacy | cialis price | cialis cialis online, buy cialis online, buy cialis order - online medical center (we take care of you)levitra online | buy levitra online | buy levitra order| buy levitra now | buy levitra pills | prices levitra | levitra mexico | levitra pharmacy | levitra price levitra online, buy levitra online, buy levitra order - online medical center (we take care of you)acomplia online | buy acomplia online | buy acomplia order| buy acomplia now | buy acomplia pills | prices acomplia | acomplia mexico acomplia online, buy acomplia online, buy acomplia order - online medical center (we take care of you)soma online | buy soma online | buy soma order| buy soma now | buy soma pills | prices soma | soma mexico | soma pharmacy | soma price soma online, buy soma online, buy soma order - online medical center (we take care of you)tramadol online | buy tramadol online | buy tramadol order| buy tramadol now | buy tramadol pills | prices tramadol | tramadol mexico tramadol online, buy tramadol online, buy tramadol order - online medical center (we take care of you)ultram online | ultram vpxl online | buy ultram order| buy ultram now | buy ultram pills | prices ultram | ultram mexico | ultram pharmacy ultram online, buy ultram online, buy ultram order - online medical center (we take care of you)vpxl online | buy vpxl online | buy vpxl order| buy vpxl now | buy vpxl pills | prices vpxl | vpxl mexico | vpxl pharmacy | vpxl price | vpxl shop vpxl online, buy vpxl online, buy vpxl order - online medical center (we take care of you)xenical online | xenical online | buy xenical order| buy xenical now | buy xenical pills | prices xenical | xenical mexico | xenical pharmacy xenical online, buy xenical online, buy xenical order - online medical center (we take care of you) sitemap.xml