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

Two programmers in one

Two programmers in one

My RubyNation 2014 talk

Jano González

June 07, 2014
Tweet

More Decks by Jano González

Other Decks in Programming

Transcript

  1. TWO PROGRAMMERS IN ONE

    View Slide

  2. @janogonzalez

    View Slide

  3. View Slide

  4. A TALE OF TWO
    DEVELOPERS

    View Slide

  5. HACKER
    V/S

    THINKER

    View Slide

  6. HACKER

    View Slide

  7. GET THINGS
    DONE

    View Slide

  8. FAST

    View Slide

  9. HACKS

    View Slide

  10. MAINTENANCE
    NIGHTMARE

    View Slide

  11. NEEDS MORE DUCT TAPE

    View Slide

  12. THINKER

    View Slide

  13. THINKS ABOUT
    ABSTRACTIONS

    View Slide

  14. THINKS ABOUT
    MAINTAINABILITY

    View Slide

  15. TOO MANY
    ABSTRACTIONS

    View Slide

  16. ANALYSIS
    PARALYSIS

    View Slide

  17. NEEDS MORE LAYERS

    View Slide

  18. MY HISTORY

    View Slide

  19. A TRILOGY OF
    MOVIES

    View Slide

  20. THE HACKER YEARS

    View Slide

  21. THE HACKER YEARS

    View Slide

  22. THE LEARNING YEARS

    View Slide

  23. THE UML YEARS

    View Slide

  24. THE UML YEARS

    View Slide

  25. THE HACKER
    WAS GONE

    View Slide

  26. UML, RUP, GoF,
    XML, ETC.

    View Slide

  27. STOCKHOLM
    SYNDROME

    View Slide

  28. EVOLUTION?

    View Slide

  29. THE ONE TRUE WAY™

    View Slide

  30. THE PATH?

    View Slide

  31. FEAR

    View Slide

  32. I WAS SO WRONG!

    View Slide

  33. EVERYDAY LIFE
    IS THE PATH

    View Slide

  34. ENTER
    RUBY

    View Slide

  35. SMALLTALK IN
    PERL’S DISGUISE

    View Slide

  36. HAPPY
    THINKER

    View Slide

  37. THINKER
    class AccountProtectionProxy
    def initialize(real_account, owner)
    @subject = real_account
    @owner = owner
    end
    !
    def method_missing(name, *args)
    check_access
    @subject.send(name, *args)
    end
    ...

    View Slide

  38. OMG! GoF NEVER
    WAS SO EASY

    View Slide

  39. HAPPY
    HACKER

    View Slide

  40. HACKER
    $1 if str ~= /(foo)+/

    View Slide

  41. ONE LINERS FTW!

    View Slide

  42. HACKER

    THINKER

    View Slide

  43. LET’S WORK
    TOGETHER

    View Slide

  44. HARMONY

    View Slide

  45. HARMONY
    (1..42).select(&:even?).
    map { |n| n * 2 }.
    reduce(&:*)

    View Slide

  46. THE PATH

    View Slide

  47. THE PATH IS
    NO PATH

    View Slide

  48. THE PATH

    View Slide

  49. WORKING TOGETHER

    View Slide

  50. HACKER

    View Slide

  51. EXPLORE
    NEW TERRITORY

    View Slide

  52. THINKER

    View Slide

  53. FIND ACCEPTANCE
    CRITERIA

    View Slide

  54. DEFINE
    COMPONENTS

    View Slide

  55. BALANCE

    View Slide

  56. DELIVER VALUE
    V/S
    DIMINISH
    TECHNICAL DEBT

    View Slide

  57. CREATIVITY
    V/S
    STANDARDIZATION

    View Slide

  58. EXAMPLE

    View Slide

  59. CASE STATEMENT
    V/S
    FACTORY + COMMANDS

    View Slide

  60. CASE
    STATEMENT

    View Slide

  61. EXAMPLE
    case account_type
    when :premium then
    # do stuff
    when :standard then
    # do stuff
    when :personal then
    # do stuff
    end

    View Slide

  62. FACTORY
    +
    COMMANDS

    View Slide

  63. EXAMPLE
    class PremiumAccount
    def initialize
    # do stuff
    end
    !
    def execute(context)
    # do stuff
    end
    end

    View Slide

  64. EXAMPLE
    class AccountFactory
    def self.create(type)
    name = "#{type.capitalize}Account"
    klass = Kernel.const_get(name)
    klass.new
    end
    end

    View Slide

  65. EXAMPLE
    AccountFactory
    .create(account_type)
    .execute(context)

    View Slide

  66. THE BEST
    APPROACH?

    View Slide

  67. IMPLICIT
    V/S
    EXPLICIT

    View Slide

  68. CLARITY
    V/S
    DRY

    View Slide

  69. CLARITY
    V/S
    SRP

    View Slide

  70. NOW
    V/S
    FUTURE

    View Slide

  71. MY HUMBLE
    ADVICE

    View Slide

  72. LEARN ABOUT
    BEST PRACTICES

    View Slide

  73. DON’T FOLLOW BLINDLY
    YOUR FUNCTIONAL GURU

    View Slide

  74. DON’T FOLLOW BLINDLY
    YOUR OO GURU

    View Slide

  75. TESTS
    +
    REFACTORING

    View Slide

  76. HOW TO IMPROVE
    IF YOU ARE A…

    View Slide

  77. HACKER

    View Slide

  78. LEARN ABOUT
    OOP & PATTERNS

    View Slide

  79. TRY IMMUTABILITY &
    SEQUENCES

    View Slide

  80. DO SEPARATE
    RESPONSIBILITIES

    View Slide

  81. THINKER

    View Slide

  82. LEARN ABOUT
    ONE LINERS

    View Slide

  83. TRY CODE GOLF

    View Slide

  84. DO EVIL STUFF

    View Slide

  85. EVERYONE

    View Slide

  86. READ A LOT OF
    CODE

    View Slide

  87. WRITE A LOT OF
    CODE

    View Slide

  88. ONE LAST ADVICE

    View Slide

  89. 守破離

    View Slide

  90. SHU
    守破離

    View Slide

  91. HA
    守破離

    View Slide

  92. RI
    守破離

    View Slide

  93. View Slide

  94. ANTIPATTERN:
    ETERNAL SHU

    View Slide

  95. ANTIPATTERN:
    START IN HA

    View Slide

  96. CONCLUSIONS

    View Slide

  97. RUBY GIVES YOU
    FREEDOM

    View Slide

  98. LETS YOU STRIVE
    FOR BALANCE

    View Slide

  99. AVOID CARGO
    CULT

    View Slide

  100. GOOD ADVICE
    V/S
    LAWS

    View Slide

  101. THERE IS
    NO TRUE PATH

    View Slide

  102. IF YOU MEET THE BUDDHA
    IN THE ROAD, KILL HIM!

    View Slide

  103. FOLLOW YOUR

    View Slide

  104. THANK YOU!

    View Slide

  105. IMAGES
    !
    • http://commons.wikimedia.org/wiki/File:Yin_yang.svg
    • http://upload.wikimedia.org/wikipedia/commons/archive/f/
    f4/20050917122925%21Janus-Vatican.JPG

    View Slide