1. Improving Large Rails Apps with Service Objects

    Nothing has improved my Rails apps more than service objects. A couple of weeks ago, I was asked to help out with an established Rails app. I found a User model that included 28 modules. All but 8 were namespaced under Users. A core object in your system, used everywhere, and it’s thousands of lines long. How many features have been bolted onto this model? When you look at a method, which feature does it belong to?

    Madness like this can be sidestepped with service objects.

    Let’s start at a time before 28 includes. Let’s start at the beginning. Imagine you’ve started a SaaS business. It’s a help desk. Soon you have clients signing up. Then their users are creating accounts and receiving support.

    Want to make your clients happy? Make their users happy. You’ve decided to add a welcome email for those users. It’ll provide a friendly hello and tips on how to use the help desk.

    Where does your new code go?

    Read More
  2. Don't tie jQuery to the Rails

    rail road tracks Photo by Kevin Moreira licensed under CC. The photo has been modified.

    It’s time for jQuery to go. It’s a great library but it’s not a part of Rails.

    I was recently auditing a site for dependencies. Skimming the list of JavaScript libraries I blew right by jQuery. Then a thought popped into my head. The bits of dynamic front-end were built using React. Where was jQuery being used?

    Read More
  3. Wait, where does what?

    No matter how much I know there are always bits that slip by. I’ve used Rails for years. Which means I’ve queried models using where for years. Even so, I recently saw someones code and thought, “that can’t work.”

    I was wrong.

    Read More
  4. Software to Maximize Your Keyboard (OS X)

    Last time I talked about buying yourself a better keyboard. Better hardware is a great step but it’s only half of the equation. There’s a lot that can be done on the software side. I’ll provide some tips and tricks that have helped me.

    Read More
  5. Buy a Better Keyboard Already

    Picture a carpenter without a saw. A guitarist with no strings. A coder with no keyboard. Look down for a moment. Those roughly one hundred keys have been between you and every line of code you’ve written.

    Be honest, how much thought have you given to your keyboard? Are you using the one that came in the box or that the company put on your desk? From what I’ve seen, most of you are.

    Chefs don’t cut with dull knives. Stop programming with a shitty keyboard.

    Read More
  6. Switching From Slate to Hammerspoon

    Window management on OS X is… well… not a strong point. I want to move windows around with ease and precision. It turns out I’m not alone. There’s no shortage of applications claiming to fix windowing and increase productivity. For a while I used Divvy. It did a fine job. Before long I realized my windows ended up in the same places. I needed to save layouts. I needed more control.

    In stepped Slate. It sounded perfect.

    Slate is a window management application similar to Divvy and SizeUp (except better and free!).

    For a long time Slate did everything I wanted. Only it hasn’t been updated since early 2013.

    While looking for a replacement I stumbled across something new.

    Read More
  7. Using Gulp with Jekyll

    I’m a fan of Jekyll. Combine it with GitHub Pages and you get a free blog that can handle tons of traffic. It’s great. It’s the best. There’s just this one thing. Jekyll handles Sass out of the box and supports CoffeeScript with a gem but I demand more. I want Sass, file concatentation, minification, automatic prefixing of CSS, live reloading, and dancing unicorns! Ok, that last one might not be available. For the rest… enter Gulp.

    Read More
  8. Duck Typing with Types of Ducks

    One of the most insidious destroyers of code is the nil. Raise your hand if you’ve had to sift through piles of functions and files to track down an unexpected nil.

    Me too.

    Ruby doesn’t come with a way to create explicit interfaces. Instead, we create implicit interfaces. These interfaces are built one method at a time. Each method sent to an object adds to that interface. If the object provided adheres to the interface then we accept it. We duck type. Our only safety net is NoMethodError.

    We can use this net to protect ourselves. We can defend against nil.

    Read More
  9. Ruby's New &.!= Operator

    Well, it’s actually two operators. Sue me. The 2.3.0 release of Ruby included the safe navigation operator, &.. It does the same thing as try! in Rails. You can chain method calls together and bail early if you hit a nil.

    In Ruby some things you don’t normally think of as method calls are in fact just that. For example, operators like !=.

    Read More
  10. Presenting: Software Development

    software is eating the world

    Last week I had the honor of presenting to a group of high school students. They attend a class at Brookhaven College that introduces JavaScript and for many of them, the very concept of programming. I was asked to talk about what software development is like as a career. They wanted the students to understand where this class could lead.

    Read More