Author Archive

Knyle Style Sheets

So I’ve been writing CSS for somewhere around 13 years now. Some might think I’ve learned the right way to write CSS in that time — but if you ask me all I’ve learned is the most efficient way to drive someone insane.

CSS is complicated. It’s not object oriented. It’s not hierarchical. It’s a specificity based cascade applied to a dynamic hierarchical data structure that few people truly comprehend. Trying to impart this knowledge on someone is a very difficult task with extremely minimal rewards. I used to think that imparting this knowledge was the path toward writing maintainable CSS within a team.

Maintainability comes from shared understanding

It’s hard to define maintainability. In my eyes it has to do with creating an shared understanding. Anyone who has owned an aircooled Volkswagen knows how to adjust valves on any other aircooled Volkswagen. This is because of one of the best technical books ever written: How to Keep Your Volkswagen Alive.

Everyone I know who owned a Bug, Bus, Ghia or Thing owns a copy of this book and understands how to work on their car. This book is in large part responsible for that shared understanding.

How can we create a shared understanding with CSS?

Documentation

For all of the talk of Object Oriented CSS, SMACSS and pre-processors like SASS/SCSS & LESS… no one is talking about documentation.

Documentation is the key to shared understanding.

Enter KSS

Inspired by TomDoc, KSS attempts to provide a methodology for writing maintainable, documented CSS within a team. Specifically, KSS is a documentation specification and styleguide format. It is not a preprocessor, CSS framework, naming convention, or specificity guideline. This means it works great with ideas like OOCSS, SMACSS, SASS, and LESS.

I’ve created a specification for KSS as well as a ruby gem to parse the documentation.

In a nutshell, KSS looks like this:

/*
A button suitable for giving stars to someone.

:hover             - Subtle hover highlight.
.stars-given       - A highlight indicating you've already given a star.
.stars-given:hover - Subtle hover highlight on top of stars-given styling.
.disabled          - Dims the button to indicate it cannot be used.

Styleguide 2.1.3.
*/
a.button.star{
  ...
}
a.button.star.stars-given{
  ...
}
a.button.star.disabled{
  ...
}

The idea is to write simple, yet machine parseable documentation such that you can automatically create a living styleguide like this one:

KSS aims to create a shared understanding

I’ve tried really hard to make sure that KSS is flexible enough to work with as many styles of CSS development as possible. It’s purpose is to create a shared understanding through code documentation and styleguides. Not to tell you how to write CSS.

And well. I think that’s an important idea. Hope you like it.

https://github.com/kneath/kss


Knyle style recruiting

Otherwise known as Kyle Neath’s guide to hiring the best people in the world: an examination into why recruiters are useless piles of humanflesh hellbent on destroying the souls of good designers and developers across the world.

Too harsh? Most likely. But here’s the thing: recruiters do not give a fuck about doing good in the world. They do not care about making people happy. They do not care about building a good company. They do not care about treating email addresses as human beings. They only care about their percentage.

Employees are the best recruiters

At its core, the idea of a recruiter never made sense. Are they going to be working with their hire? Are they a designer, developer, copywriter or someone who knows what kind of skills and personality traits to look for?

No. They’re salespeople. And I bet they’re great at hiring other salespeople.

It just seems so obvious to me that employees make the best recruiters. Recruiters have nothing to gain from a good employee, but employees have everything to gain. If you consider yourself a manager, don’t you want to be responsible for building the team of people you’re going to manage? If you’re a developer, don’t you want to work with other great developers?

How I hire people

I happen to think I’ve become pretty good at recruiting over the years. We’ve built a pretty amazing team at GitHub, and I’d like to explain how I go about finding the next GitHubber.

Friendship

If you want to hire great designers and developers, you should be friends with them. Be interested in who they are and what they do. This is not rocket science. When you’re friends with someone you’ll notice when they’re frustrated with their job or know when they’re looking for something new. And even if they’re not looking for something new — maybe they have a (designer/developer) friend who is.

Research

Take time to look up potential hires online. If you’re hiring in the tech industry, they’re almost certain to have an internet presence. Look up their current job. See what they do. Take a look on dribbble, browse their code on GitHub — look at their work. More often than not, it’s completely unnecessary to interview for skills. You can find that out with a half hour online. Who knows, you might even find someone new to hire in the process.

Research is the proper tool to understand whether someone has the skills to work for you.

Grab a beer

It’s vitally important that you sit down face to face and grab a beer with every potential hire. Or sit down for dinner. Smoke a joint. I don’t care what it is — you need to sit down in a relaxed environment and figure out what kind of person they are.

Talk about their family, friends, hobbies, current job, dream job — anything you can think of. Some good things to figure out:

  • Is this person a good human?
  • Do they have a drive to build good things?
  • Do they want to work on the things you want them to?

Grabbing a beer will help you figure out if someone will fit in.

Job boards, Twitter, and advertising

I always try and use my personal connections to find potential hires first, but sometimes I come up empty handed. When that fails, you need to stretch out and get some new blood. There’s no shortage of Job boards out there: GitHub Jobs, Dribbble, 37Signals, Authentic Jobs — the list goes on. Pick a few and post some ads. Maybe sponsor a local meetup.

But remember you’re posting an advertisement. This isn’t a fact sheet. Make that shit sexy. Make potential hires read it and think I want that job. Explain specifically what they’ll be doing day to day, what they’ll be responsible for, and who they’ll be working with. Explain what your company is. Explain what it is your company wants to do.

And if you have anything listed under requirements, you better damn well mean it. Don’t ask for a college degree if you don’t actually require it. That’s just dumb.

Credit where credit is due

These ideas aren’t exactly unique, and in fact they’re really not even mine.

In 2004 I was working for an agency and we hired a full time recruiter. Props to that man for showing me just how incompetent recruiters can be. Never in my life did I think someone would create a MySpace account and contact every teenager in the city trolling for leads. He really redefined the phrase unqualified candidate.

In 2009 I started working with Chris, Tom and PJ. For every person that thinks GitHub’s success is due to luck — I want to remind you how important the people are in a successful company. And these guys spend a lot of time making sure we have the right people.

Spend time on recruiting: it’s important.


Mustache, ERB and the future of templating

There are days that I feel like I’ve spent the better part of my life inside templating languages. I’ve rocked hundreds of different styles of templates over the past 8 years. Smarty, vBulletin templates, generations of Wordpress, J2EE, XSLT, CFML, ERB, HAML, Mustache and every form of in-house bastardized template language that exists.

So when I say that {{ mustache }} is my favorite templating language I’ve ever worked with, I mean it with a great deal of sincerity and experience. It’s syntactically elegant, focused on output (HTML), encourages documentation, and discourages unmaintainable magic. I want to use it everywhere.

I mustache you, why mustache?

-"Mustache

Mustache is more than a syntax. It’s a different approach to traditional templating — mustache templates have no logic. The template files themselves are HTML and mustaches:

<table class="devlist">
  {{#developers}}
  <tr>
    <td class="name">
      <h4><a href="{{ show_url }}">{{ name }}</a> <em>({{ github_username }})</em></h4>
      <p class="languages">{{ languages }}</p>
    </td>
    <td class="location">{{ location }}</td>
  </tr>
  {{/developers}}
</table>

You cannot modify variables. You cannot apply filters. You can only output variables or a collection of variables. Everything else happens inside of a view. A view can be written in any language of your choosing: C, Objective-C, Ruby, Python, Javascript, etc. I’ll use Ruby since that’s what we use:

module Jobs
  module Views
    class Developers < Layout

      def developers
        @results.entries.map do |hit|
          name = hit["fullname"].empty? ? hit["username"].capitalize : hit["fullname"]
          {
            :name => name,
            :github_username => hit["username"],
            :location => hit["location"],
            :show_url => '/developers/' + hit["username"],
            :languages => hit["language"]
          }
        end
      end

      def developers_count
        @results.total_hits rescue 0
      end

    end
  end
end

It’s just a good old Ruby class. Oh the wonder you can do with a class! Include modules, extend classes (such as that Layout class), and define any method you so desire. With any documentation your heart desires (something that’s missing from every templating strategy I’ve ever used).

I thought I loved Mustache a year ago, but over time I’ve learned just how revolutionary separating templates from views is toward maintainability and collaboration. Anyone who knows HTML can edit Mustache templates. And all the magic that happens on the whole V side of MVC can be fully documented and separated into re-usable Ruby classes and modules.

You want me to switch templating languages on my legacy app?

For all this talk, the application I spend most of my time working on is still ERB. In fact, the rails app that powers GitHub has over 500 erb templates. We have dozens of people throwing hundreds of commits a day at the codebase in over 150 branches. Switching to Mustache would be a disaster requiring everyone to stop development, switch patterns, and introduce an unknown number of bugs to our customers. A shitty trade.

I don’t want to stop new feature development, but I do want better templates. And I know that Mustache is the direction I’d like to go. Luckily for me, I work with the smartest people in the world. A little while ago Simon introduced a new templating strategy that I really like.

Mustache-style ERB templates

We’ve started using the mustache style but completely within ERB — we haven’t modified the template rendering chain at all. Inside of a new helper, we’ll create a view class:

module NavigationHelper
  class RepositoryNavigationView
    include ActionView::Helpers::NumberHelper

    attr_reader :current_user, :current_repository

    def initialize(user, repo)
      @current_user = user
      @current_repository = repo
    end

    # What symbols should we trigger highlighting for various tabs?
    #
    # Returns an array of symbols.
    def highlights_for_code
      [:repo_source, :repo_downloads, :repo_commits, :repo_tags, :repo_branches]
    end

    def highlights_for_pulls
      [:repo_pulls]
    end

    def highlights_for_issues
      [:repo_issues]
    end

    # Should we show the wiki tab? We try and show it when it's useful to
    # someone using these rules:
    #
    # - Never show it if the wiki is disabled under the admin section.
    # - Show it if you have admin access to the repository
    # - Show it if there is content
    #
    # Returns true to show the tab.
    def show_wiki?
      return false unless current_repository.has_wiki?
      return true if logged_in? && current_repository.pushable_by?(current_user)
      current_repository.wiki.page_count > 0
    end

  end
end

Nicely documented, isolated from application-wide helpers and easy to find. Inside of the html.erb, create a new instance of this view object:

<% view = NavigationHelper::RepositoryNavigationView.new(current_user, current_repository) %>

<% unless @omit_repository_toolbar %>
  <ul class="tabs">
    <li><%= selected_link_to "Code", code_path, :highlight => view.highlights_for_code %></li>
    <li><%= selected_link_to "Network", network_path, :highlight => view.highlights_for_network %>
    <li><%= selected_link_to "Pull Requests", pull_requests_path, :highlight => view.highlights_for_pulls %></li>

    <% if view.show_issues? %>
      <li><%= selected_link_to "Issues", issues_path, :highlight => view.highlights_for_issues %></li>
    <% end %>

    <% if view.show_wiki? %>
      <li><%= selected_link_to "Wiki", wikis_path, :highlight => view.highlights_for_wiki %></li>
    <% end %>

    <li><%= selected_link_to "Stats &amp; Graphs", graphs_path, :highlight => view.highlights_for_graphs %></li>
  </ul>

  <%= render_subnav 'repositories/code',        view.highlights_for_code %>
  <%= render_subnav 'repositories/network',     view.highlights_for_network %>
  <%= render_subnav 'repositories/graphs',      view.highlights_for_graphs %>
  <%= render_subnav 'repositories/wiki',        view.highlights_for_wiki %>
<% end %>

If you’re used to regular ERB templates it’s immediately obvious where this data comes from — it’s right at the top of the file! Ack the project for RepositoryNavigationView and you’ve found your view class. No magic.

One huge advantage of this tactic is that you can still use all the same Rails/ERB shortcuts for quick prototyping. If someone doesn’t want to learn the new template strategy right away, they can use the same methods they’ve been using for years.

Graceful upgrade path

Switching templating languages is something that needs to be done gracefully when you’re working with others. Ripping out everyone’s foundation is a recipe for unhappy developers. Rails is all about patterns, and sticking to those patterns is really important.

This strategy allows us to slowly convert the codebase to a better documented, view/template separation that anyone who’s worked with ERB can understand. And if we choose to switch to true-and-blue Mustache some day, our code will be 80% there already.


Brew Methods

A wonderfully simple site dedicated to the art and style of creating fine coffee. Learn how to use that Chemex properly!


Design Hacks for the Pragmatic Minded Video

The Ruby on Ales folks got around to publishing the video of my Design Hacks talk. The audio is a little weird in the begining, but hang on — it clears up a few minutes in.


  •   
  • Copyright © 1996-2010 BlogmyQuery - BMQ. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress