Belfast Ruby - Interesting things from the GitHub codebase
As part of Break (http://breakconf.org), I gave a talk at the Belfast Ruby (http://belfastruby.com/) meetup talking about a few interesting things from the GitHub codebase.
• Responsive is better than fast. • It’s not fully shipped until it’s fast. • Anything added dilutes everything else. • Practicality beats purity. • Approachable is better than simple. • Mind your words, they are important. • Speak like a human. • Half measures are as bad as nothing at all. • Encourage flow. • Non-blocking is better than blocking. • Favor focus over features. • Avoid administrative distraction. • Design for failure. • Keep it logically awesome.
class Teams::ShowView < ViewModel attr_reader :team def show_pending_invitations? current_user.invitations_enabled? && team.pending_invitations.any? && team.adminable_by?(current_user) end end
class NewThingController < ApplicationController before_filter :ensure_new_thing_enabled def ensure_new_thing_enabled render_404 unless new_thing_enabled? end end
require "dat/science" class YourApp::Widget def allows?(user) experiment = Dat::Science::Experiment.new "widget-permissions" do |e| e.control { model.check_user(user).valid? } e.candidate { user.can? :read, model } end experiment.run end end
require "dat/science" class YourApp::Widget include Dat::Science def allows?(user) science "widget-permissions" do |e| e.control { model.check_user(user).valid? } e.candidate { user.can? :read, model } end end end