Thoughts on software craftsmanship.

Architecture Without an End State

After he appeared on Ruby Rogues, I watched Michael Nygard’s recent talk Architecture Without an End State and found it fascinating. Nygard argues patiently and convincingly against the “One System To Rule Them All” approach to architecture, through which companies embark on multi-year plans to consolidate all of their data into a single system of record—projects which Nygard says dramatically that he has never seen reach completion. The turnover rate for CTOs is shorter than the time to complete such projects, so more commonly a new CTO will come in with a new plan (only to leave before its completion), relegating the existing plan to the dustbin of “legacy” projects.

Continue reading...

How to Count With ActiveRecord

Counting records returned from the database by ActiveRecord is quite a bit more complicated than you’d expect, but that’s the price of Rails’ magic and the invisible efficiency it gives you behind the scenes. ActiveRecord has its own implementation of Ruby’s size, any?, and empty? methods which behave differently than their array counterparts. Understanding how each works will help you write more efficient code when dealing with database records.

Continue reading...

Load Testing Rails Apps with Apache Bench, Siege, and JMeter

Your app works great in development and in production with dozens of users. Now, the marketing team wants to send out a blast: can the app handle hundreds? Thousands? How many users can it handle? These are tricky questions to parse, let alone answer, but any answer is going to involve some form of load testing.

Continue reading...

Writing Fast (and Idiomatic) Ruby

Ruby hero Erik Michaels-Ober gave a superbly userful talk (video, slides) at this year’s Barcelona Ruby Conference. In it, Michaels-Ober offers up a dozen-or-so cases where some casual Ruby code can be made both faster and cleaner by using built-in Ruby features.

Continue reading...

This Week I Learned #13

Replacing jQuery’s fade functions with silky-smooth CSS transitions both in and out of hover states, a Git strategy for extracting individual commits from a branch’s tree, and how to search a Git repo for a commit by name (which Github unfortunately doesn’t support).

Continue reading...

How To Write CSS That Scales

I’ve been writing CSS for about eight years now, and every time I do it better than the last time. Which is to say, I’ve never gotten it right. So of course, what I’m about to share isn’t The One Right Way™ to write CSS. But it is, I hope, a valuable collection of practices to avoid the many mistakes I’ve made and seen. Ultimately, what we want is for our code to scale: to continue to work well as we add more content, more code, and more people to the equation.

Continue reading...

This Week I Learned #12

This week, I learned how to clean up complex or repeated validations with ActiveModel’s custom validator objects; how to write cleaner, more intention-revealing Sass with pure functions; and a useful but little-known CSS selector with a lot of potential.

Continue reading...

Provisioning a LAMP Stack and WordPress with Chef, Bonus Part: Deploying Themes with Git

Having set up a server and WordPress installation without manually FTPing a single file, it would be a shame to have to ask Chef to install an FTP client so that we can upload and update our theme files the old-fashioned way. Fortunately, we don’t have to! Matt Banks has an excellent technique for using Git to deploy WordPress themes, which I’ll be automating with a Chef recipe.

Continue reading...