Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nobody Will Train You But You

Zach
April 29, 2013

Nobody Will Train You But You

Why do we all know a developer who has been pounding out unmaintainable code for a decade or more? Why do people "believe in TDD but I don't have time to write tests during crunch?" How is it that we have an entire industry based around rescuing teams from acutely awful Rails apps?
It's because on the job experience is a poor teacher; plateauing as soon as the developer is able to ship code that meets requirements. Schools teach Computer Science which is only tangentially related to being a developer and most kata's are approached incorrectly, giving no value at best, and reinforcing poor practices at worst. On top of all this, our pairs (for the lucky ones who pair program) probably have not shown us anything new in months.
This presentation will give specific, concrete steps on how to slowly and steadily improve our game through practice and hard work. I'll identify what skill Rails developers should be focusing on and walk the audience through how to target and eliminate these weaknesses so that nothing but white hot joy streams out of our fingers and into our apps. There's no magic here, no secrets, and no hacks; just you and me working our butts off until we suck a little less.

Zach

April 29, 2013
Tweet

More Decks by Zach

Other Decks in Programming

Transcript

  1. •Googled Rails - May 02, 2012 •Junior Dev - August

    22, 2012 •Developer - October 17, 2012 Wednesday, May 8, 13
  2. •Googled Rails - May 02, 2012 •Junior Dev - August

    22, 2012 •Developer - October 17, 2012 •Test Double - April 22, 2013 Wednesday, May 8, 13
  3. •Googled Rails - May 02, 2012 •Junior Dev - August

    22, 2012 •Developer - October 17, 2012 •Test Double - April 22, 2013 •RailsConf - April 29, 2013 Wednesday, May 8, 13
  4. demo what’s the database password? priority bug excuse me meeting(s)

    Attempting to get across the cost of googling by comparing it to other distractions. Wednesday, May 8, 13
  5. names = ['Last, First M', 'Last,First!@'] def word_after_comma end #=>

    ["First", "First"] 12 First Names - Front Wednesday, May 8, 13
  6. names = ['Last, First M', 'Last,First!@'] def word_after_comma /,\s?(\w+)/ end

    first_names = names.map { |x| x.match(word_after_comma)[1] } #=> ["First", "First"] 13 First Names - Back Wednesday, May 8, 13
  7. config = YAML.load_file(path) # => {"ip"=>"0.0.0.0", "port"=>"8080"} # => {:ip=>"0.0.0.0",

    :port=>"8080"} # active support # => {:ip=>"0.0.0.0", :port=>"8080"} 14 Symbolize Keys - Front Wednesday, May 8, 13
  8. config = YAML.load_file(path) # => {"ip"=>"0.0.0.0", "port"=>"8080"} config.each_with_object({}) { |(k,v),h|

    h[k.to_sym] = v } # => {:ip=>"0.0.0.0", :port=>"8080"} # active support config.symbolize_keys # => {:ip=>"0.0.0.0", :port=>"8080"} 15 Symbolize Keys - Back Wednesday, May 8, 13
  9. you will not need them your googles The darker colored

    slides are supposed to be capstone points. What the talk is about. Wednesday, May 8, 13
  10. Stuff I don’t know that I don’t know Stuff I

    know that I don’t know Stuff I know I stole this idea from a blog post that I can no longer find. Wednesday, May 8, 13
  11. “Wisdom, like mustaches and mullets, must be earned not grown.”

    Leon Gersing Used to have a picture of my dad here, removed for being distracting. I miss the picture. Wednesday, May 8, 13
  12. “Process can not be inferred from product any more than

    a pig can be inferred from a sausage. It is possible, however, for us to follow the process forward from blank page to final draft and learn something of what happens.” Don Murray Wednesday, May 8, 13
  13. class SearchEngine def self.count_results(query) google = Google::Search::Web.new(:query => query) google.response.estimated_count

    end end describe SearchEngine do it "counts results" do beos = SearchEngine.count_results("beos") microsoft = SearchEngine.count_results("microsoft") microsoft.should be > beos end end Decoupled Tests Wednesday, May 8, 13
  14. class CachedScore < ActiveRecord::Base attr_accessible :term, :score class NoScore <

    RuntimeError; end def self.for_term(term) cached_score = find_by_term(term) or raise NoScore result = cached_score.score result || RockScore::NoScore end def self.save_score(term, score) score = nil if score == RockScore::NoScore create!(:term => term, :score => score) end end Single Responsibility Wednesday, May 8, 13
  15. Controller Model domain logic database JSON api cache logic 3rd

    party api wrapper 3rd party api Wednesday, May 8, 13
  16. NoMethodError: undefined method `each' for nil:NilClass> with backtrace: # ./app/models/stuff.rb:7:in

    `contrive' # ./spec/models/stuff_spec.rb:11:in `block (3 levels) in <top (required)>' # ./spec/models/stuff_spec.rb:10:in `block (2 levels) in <top (required)>' Nil Stack Trace Wednesday, May 8, 13
  17. class Performance NoScore = Class.new def self.for_employee(employee) hits = MetricsService.get

    employee value = calculate_for_employee hits value || NoScore end #... end Sentinel Object Wednesday, May 8, 13
  18. NoMethodError: undefined method `each' for Performance::NoScore > with backtrace: #

    ./app/models/stuff.rb:7:in `contrive' # ./spec/models/stuff_spec.rb:11:in `block (3 levels) in <top (required)>' # ./spec/models/stuff_spec.rb:10:in `block (2 levels) in <top (required)>' Sentinel Stack Trace Wednesday, May 8, 13
  19. Toys Not a great shot, but it does the trick.

    Feels half-assed. Wednesday, May 8, 13