mike raimondi

Inverse Associations in Rails

Consider the following association:

class CrazyCatLady < ActiveRecord::Base
  has_many :cats
end

class Cat < ActiveRecord::Base
  belongs_to :crazy_cat_lady
end

Now, imagine you did:

CrazyCatLady.first.cats.first

OK, this will query the database for the first CrazyCatLady, then query again for all cats associated with that record. Fair enough. But what if we do this:

CrazyCatLady.first.cats.first.crazy_cat_lady

Aside from being a bit silly, this does everything the first statement does, then queries the database a third time to find the CrazyCatLady associated with the first cat. But Rails already has this information! Why is it querying the database again?

More

On Top of Spaghetti, All Covered With Cheese

I say we take off and nuke the entire site from orbit. It’s the only way to be sure.

Ellen Ripley

You thought implementing the code would be relatively easy. You thought you could bang it out in an hour and be done. You thought you’d make it home on time today. You were wrong.

And now, you’ve got a big heaping plate of spaghetti code in front of you. That is, your code is massively interdependent and there is no clear way forward to testing small, understandable parts of the code. How did you get in this mess? What would prevent it from happening again? And how the heck are you going to fix all this barely intelligible code?

More

Unexhaustion

We’ve all been there. It is late in the day. You’re drained. You have a task that you know needs to get done, but every attempt to finish seems to get nowhere. You imagine all the work that lies ahead of you. If you’re like me, you may start having negative thoughts about yourself. How do we recover from exhaustion?

More

First post, or, git commit -m "Initial commit"

Politics isn’t about Policy

Robin Hanson

As I start to seriously pursue becoming a developer, I’m learning that coding isn’t about code. So, why the name “Unlimited Code Works” (besides the dumb reference(to a reference))? For one, as a newbie developer it is really difficult to step out of the limits of my code. In a sense, I’m stuck inside my severely constrained programming toolkit. Of course, this will change over time. But right now, I’m doing my best to see the problems I’m solving from an outsider’s perspective. My work must always be pushing beyond the limits of the code I can presently write. It is the only way I’ll continually improve.

More