Test Behavior, not Configuration

May 23, 2016

I’ve become re-acquainted with the pattern of testing ActiveRecord classes using stuff like expect(parent).to belong_to(:child) and I just don’t understand why anyone would ever write a test like that. It provides no value, and the implementation provided by shoulda isn’t actually testing the behavior. It’s testing configuration.

Announcing Rails 6: An Imagined Keynote

May 17, 2016

Just got back from RailsConf. It was a great Ruby & Rails conference, but I was struck by the dearth of talks about new features of Rails 5—because there just aren’t many. I thought back to what excited me about Rails in the first place—the baked-in conventions, convenience, encouragement of good practices.

Justin Searls gave a talk not about RSpec but about how Rails is losing mindshare, losing favor. Is Rails losing relevance? I hope not, but it’s easy to see how someone less emotionally invested than me might see it that way.

I’m trying to write about this without complaining. This is my fifth attempt. It’s hard not to just rant about Rails’ failings, so I’m going to try to be constructive by outline a fantasy roadmap for Rails 6.

I tried very much to think about this without going against the “Rails Doctrine”, and have written this as if it were an Apple-style keynote. The theme is Progress.

The 'Type Wars' Are Far From Over

May 03, 2016

Uncle Bob penned an interesting piece called Type Wars. It’s ostensibly a history of the fashion around how types are handled in programming languages. It, unfortunately, comes to the conclusion that “TDD and unit tests means you don’t need statically-enforced types”. This is not true.

He initially describes how C had types, but they weren’t enforced at compile- or run-time. This is bad (he says and I agree) and then talks about two ways to enforce type safety (i.e. require that the you are using the correct types). In Java, the compiler requires it or the code won’t even run. In Smalltalk, the runtime requires it only at runtime. And, according to Uncle Bob, the latter is preferable because you have unit tests. This is not true (he also overstates the burden required in having types enforced at compile time—just because Java is terrible doesn’t mean the concept is).

In particular, he creates a false equivalence between unit testing and static type checking:

You don’t need static type checking if you have 100% unit test coverage.

Not true.

Technology is Terrible

April 10, 2016

I get into my hotel at around 8:30pm. I want to watch NXT Takeover on the WWE network and then go to bed. I unpack and then put my Amazon Fire Stick in the HDMI port on the TV.

I start looking for an outlet to plug it in. Nothing close. The armoire weighs a ton and both of the plugs behind it are used up anyway.

Ok, I can just watch on my laptop. Open it up. Keyboard and trackpad not responding. Reboot. No Mac Startup Chime. Keyboard still not working. Reboot. Same. Reboot and hold down Option. Nothin. Repeat with Shift. Repeat with Command Option P M. Wait. Reboot into recovery mode. Computer insists I turn on my Bluetooth keyboard and mouse. Which I don’t have. Fuck.

I just want to watch an hour of pro wrestling.

Pour myself a drink.

Plug the Amazon Fire Stick into my USB battery. Turn on Tv and it works.

Connect to hotel wi-fi. Amazon browser not compatible with the OMNI’s interstitial. Go into “cursor mode” and I’m literally surfing the web with up/down/left/right/submit.

Select premium Internet. Fuck it, I want this to work. Enter my name and room number. I’m in!

Navigate passed about 20 apps that I could download, but have not. WWE is at the end and it’s already downloaded.

OF COURSE I have to sign in! Otherwise, someone might have stolen my Fire stick and started watching 1990’s WCW repeats on my dime!

Open phone, launch 1Password to get my login details. Sometime in the past my phone rebooted so I can’t use TouchID to get in. Enter my very long and easy to mistype pass phrase. Thankfully I get it right the first time.

Back to the Fire stick, I log in to the WWE network. It’s really. really. slow.

Find NXT Takeover and start it up. Stuttering and buffering would be an understatement. I let it ride. After about 10 minutes, I’ve seen 2 minutes of the event, doled out in 5 second bursts. Fuck.

Second drink is poured.

Ok, I’ll watch something else. Maybe it’s WWE. The tech behind their network is not very robust.

Hulu! I can catch up on the terrible superhero shows I like. Or Netflix! Can watch Walking Dead. Both require downloading an app and surely logging in. I’m done logging into things for the night.

Oh, I’m still in season 1 of Veronica Mars! And it’s only on Amazon Prime!

Amazingly, it remembers the last episode I watched (God knows I don’t). Start it up.

“Previously on Veronica Mars…” and then the screen turns solid green and does nothing but glitch.

Ok, maybe it’s this episode. I’ll skip it and not worry about missing too much. Start the next episode.

“Previously on Veronica Mars…” and then the screen turns solid green and does nothing but glitch.

I just want to watch TV and go to bed.

Ok, what else is there? The Wire season 1. Haven’t watched it in ages and could honestly settle for Idris Elba reading he phone book for 2 hours. You know what would be awesome? A sitcom around all the time Stringer Bell spent in community college. I mean, they had to have group projects so I can see hours of fun watching him and three 19 year olds try to make business plans for video stores or whatever.

Anyway, this finally works. I watch a couple episodes without incident. Finally. It’s bleaker than I remember.

It’s 11pm and I still want to watch wrestling. Flip back to WWE and now it’s working. But I’m tired. Fast forward to Baylee vs Asuka for the women’s title. Baylee loses. Fucking hell.

“Why You Need a JavaScript Framework” in March's PragPub

March 03, 2016

In March’s PragPub, I’ve got an article titled “Why You Need a JavaScript Framework”.

Remember that application you were working on that started out needing just a bit of JavaScript? And then it needed more? And then just a bit more? And then you had a complete mess on your hands?

You can avoid that next time by using a front-end application framework right from the start.

The issue is a couple bucks. Check out the other contents here.

Rails, Angular, Postgres, and Bootstrap is in print!

January 22, 2016

About a year ago, PragProg approached me to see if I was working on anything book-worthy. I’d just created https://angular-rails.com to document the pain of configuring Rails to do something it clearly didn’t want to do—let you write an application with lots of front-end. Meanwhile, I’d been learning more and more how great Postgres is.

The result is my new book “Rails, Angular, Postgres, and Bootstrap: Powerful, Effective, and Efficient Full-Stack Web Development”. It’s been in beta for a while, but official print verison is now for sale.

You can buy it now and start embracing the full stack of web development using some awesome tools that will serve you well for years to come!