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

Rules

Sandi Metz
September 15, 2013

 Rules

We're iconoclasts who reject arbitrary constraints yet long for
understandable, predictable, changeable applications. We want code that
follows rules yet we refuse to let rules to get in our way. We're
deeply attached to the little rules that help get things done (No
trailing whitespace! Indent using two spaces!) and despise the big,
complicated ones that impose one-size-fits-all straitjackets on
otherwise sane programming problems.

This talk proposes 5 'little' rules for writing object-oriented code.
These rules are determinedly simple yet produce code that experts love
and novices can be trusted to change; they fill the space between
anarchy and order with practical, common sense. The rules guide without
impeding, help without hindering and constrain without binding, and let
you create applications that are easy to change and fun to work their
whole life long.

Sandi Metz

September 15, 2013
Tweet

More Decks by Sandi Metz

Other Decks in Programming

Transcript

  1. @sandimetz Sep 2013 self interest identity/status authority order social sanctions

    inherent sanctions ignorance habit 36 Sunday, September 15, 13
  2. @sandimetz Sep 2013 2 class names per rails controller action

    (business, presenter) 43 Sunday, September 15, 13
  3. @sandimetz Sep 2013 100 lines per class    5 lines

    per method    4 params per method    1 ivar per view    2 class names per controller action No More Than 45 Sunday, September 15, 13
  4. @sandimetz Sep 2013 Using Rules to Screen for Cooperative Types:

    Rule-Following and Restraint in Common Pool Resource Systems 68 Sunday, September 15, 13
  5. @sandimetz Sep 2013 Using Rules to Screen for Cooperative Types:

    Rule-Following and Restraint in Common Pool Resource Systems 69 Sunday, September 15, 13
  6. @sandimetz Sep 2013 1 1 1 1 360 ∞ 90

    Sunday, September 15, 13
  7. @sandimetz Sep 2013 1 1 1 1 360 2 ∞

    90 Sunday, September 15, 13
  8. @sandimetz Sep 2013 Round 2 180 - 30 = 150

    99 Sunday, September 15, 13
  9. @sandimetz Sep 2013 Round 2 180 - 30 = 150

    150 / 4 = 37.5 100 Sunday, September 15, 13
  10. @sandimetz Sep 2013 180 Round 2 1 1 1 1

    2 102 Sunday, September 15, 13
  11. @sandimetz Sep 2013 self interest identity/status authority order social sanctions

    inherent sanctions ignorance habit 120 Sunday, September 15, 13
  12. @sandimetz Sep 2013 Credits http://www.flickr.com/photos/paul-w-locke/1792803096/ Cannibal Pumpkins http://www.flickr.com/photos/john_pp/3155064087/ 100K Speed

    limit sign on cliff with hiker http://www.flickr.com/photos/paphio/272769602/ Cops cheek kissing http://www.flickr.com/photos/pixel8-rcrd/5791227393/ kid winning contest http://www.flickr.com/photos/fluffy_steve/2537798898/ two goths http://www.flickr.com/photos/bobjagendorf/3064198102/ wall street shuffle http://www.flickr.com/photos/pdsphil/278060802/ rubyconf room 2006 http://www.flickr.com/photos/danicuki/6319528505/ konstanin and jose http://www.flickr.com/photos/lucasrenan/5142409437/ 3 ruby nerds, 10/26/2010 http://www.flickr.com/photos/85529750@N00/5200928365/ pope barcelona http://www.flickr.com/photos/nathaninsandiego/3783772122/ umpire http://www.flickr.com/photos/rrrodrigo/4664885112/ matz http://www.flickr.com/photos/85529750@N00/5200928365/ pope barcelona http://www.flickr.com/photos/nathaninsandiego/3783772122/ umpire http://www.flickr.com/photos/rrrodrigo/4664885112/ matz http://www.flickr.com/photos/z_wenjie/7820625836 pansies http://www.flickr.com/photos/haikugirl/4813516858/ trees http://www.flickr.com/photos/emsef/2407145479/ bus stop queue http://www.flickr.com/photos/theretrographer/9228096325/ rows of jail cells brightly lit 126 Sunday, September 15, 13
  13. @sandimetz Sep 2013 Credits http://www.flickr.com/photos/jakebouma/102485568/ Car cliff warning http://www.flickr.com/photos/burge009/5215723703/ free

    tatoos http://www.flickr.com/photos/singularitysummit/6261754179/ one swarming robot http://www.flickr.com/photos/singularitysummit/6262287656/ swarming robots swarming http://www.flickr.com/photos/osakasteve/17178084/ swarming robots in a line http://en.wikipedia.org/wiki/Social_rule_system_theory Kinbrough, Erik O., Vosroknutov, Alexander (2012 draft), Using Rules to Screen for Cooperative Types: Rule-Following and Restraint in Common Pool Resource Systems 127 Sunday, September 15, 13