Refactoring: Decision making in Rails projects

Refactoring: Decision making in Rails projects

Having more fun, bring more value, and keep things simple.

D51af99491ce4b25b808c44175d8dea2?s=128

Jeremy Baker

January 13, 2017
Tweet

Transcript

  1. 1.

    The limit in any organization isn’t resources or time. It’s

    energy & motivation. Tom Chi Former Head of Experience - Google X
  2. 3.
  3. 4.
  4. 5.
  5. 6.
  6. 7.

    Refactoring photo by tim marshall Changing how the code is

    written without changing what it does.
  7. 8.

    For each desired change, make the change easy (warning: this

    may be hard), then make the easy change. Kent Beck creator of extreme programming twitter.com/kentbeck/status/250733358307500032
  8. 11.

    1. Decide a change should be made 2. Pick a

    code smell Steps photo by patrick mcmanaman
  9. 12.

    Long Method Large Class Primitive Obsession Long Parameter List Data

    Clumps Switch Statements Temporary Field Refused Bequest Alternative Classes with Different Interfaces Divergent Change Shotgun Surgery Parallel Inheritance Hierarchies Comments Duplicate Code Lazy Class Data Class Dead Code Speculative Generality Feature Envy Inappropriate Intimacy Message Chains Middle Man Incomplete Library Class photo by pete fabian Classic Smells
  10. 13.

    Long Method Large Class Primitive Obsession Long Parameter List Data

    Clumps Switch Statements Temporary Field Refused Bequest Alternative Classes with Different Interfaces Divergent Change Shotgun Surgery Parallel Inheritance Hierarchies Comments Duplicate Code Lazy Class Data Class Dead Code Speculative Generality Feature Envy Inappropriate Intimacy Message Chains Middle Man Incomplete Library Class photo by pete fabian Classic Smells Bloaters Change Preventers Dispensables Couplers OO Abusers
  11. 14.

    1. Decide a change should be made 2. Pick a

    code smell 3. Remove that code smell Steps photo by patrick mcmanaman
  12. 15.

    1. Decide a change should be made 2. Pick a

    code smell 3. Remove that code smell Steps (DO NOT GET DISTRACTED) photo by patrick mcmanaman
  13. 16.

    1. Decide a change should be made 2. Pick a

    code smell 3. Remove that code smell 4. Repeat until desired change is easy Steps (DO NOT GET DISTRACTED) photo by patrick mcmanaman
  14. 18.

    Better Teachers Exist! Try these ruby related shortcuts… www.sandimetz.com/99bottles www.youtube.com/watch?v=PJjHfa5yxlU

    www.youtube.com/watch?v=59YClXmkCVM Sandi Metz - Get a whiff of this Katrina Owen - Succession www.youtube.com/watch?v=DC-pQPq0acs Ben Orenstein - From Good to Great
  15. 20.

    photo by ᨬឡد ng The product is the behavior change

    you cause in your users. It is not the application you’re building. Tom Chi Former Head of Experience - Google X
  16. 24.
  17. 25.
  18. 26.
  19. 27.

    The initial time spent implementing a feature is one of

    the least interesting data points to consider when weighing the cost and benefit of a feature. Kris Gale Former VP Eng, Yammer firstround.com/review/The-one-cost-engineers-and-product-managers-dont-consider/
  20. 28.

    ... toggle: function (list) { ga( "send", “event", “Interface”, “toggle”,

    “Communication Preview Tasks” ); list.toggleClass('is-expanded'); } ...
  21. 34.
  22. 35.
  23. 36.

    There is nothing so useless as doing efficiently that which

    should not be done at all. Peter Drucker Old-School Management Consultant
  24. 37.

    Is hosting a core competency of ours or value we

    deliver for customers? QUESTION #
  25. 38.
  26. 39.

    • Save time • Get peace of mind • Less

    documentation that you need to maintain • Less training • Less ongoing maintenance • Less specialty knowledge • Gives you more time to focus on the real value you can deliver
  27. 45.
  28. 46.

    For each desired change, make the change easy (warning: this

    may be hard), then make the easy change. Kent Beck creator of extreme programming twitter.com/kentbeck/status/250733358307500032
  29. 48.

    Dispatcher Store View Action React View / Serializer Model Migration

    Rails 1,061 lines of JS code 17 files + JS testing + Documentation
 + Browser support The core application
  30. 50.

    View / Serializer Model Migration Rails Server-Side JS Responses (.js.slim)

    signalvnoise.com/posts/3697-server-generated-javascript-responses
  31. 51.

    ruby: id = ‘#’ + dom_id(@task, :checkbox) content = escape_javascript(render(partial:

    'shared/task/checkbox', locals: { task: @task })) $(‘#{id}’).replaceWith(“#{content)}"); ruby: url = complete_task_path(task_id: task.id, format: :js) if task.complete? method = :delete image_path = 'icons/icon-checkbox-on-blue.png' else method = :post image_path = 'icons/icon-checkbox-off.png' = link_to url, remote: true, method: method, id: dom_id(task, :checkbox), class: 'js-checkbox' = image_tag image_path shared/task/_checkbox.slim task_status/create.js.slim
  32. 55.

    ..a simpler design can suggest simplifying the organization and reducing

    the budget, which can be contrary to conventional incentives… Mel Conway Educator, Author of Conway’s Law melconway.com/Home/pdf/simplify.pdf
  33. 56.

    I think I just shed a tear. This is GREAT!

    Zipline makes my job SO MUCH EASIER! VP Operations One of the world’s largest retailers Communications Director One of the world’s largest retailers
  34. 57.

    [Zara doesn’t] run their factories at 100% utilization. They realized

    that running them at 80% meant that they could slip projects into the pipeline on short notice and ultimately sell more. Adam Pisoni Former CTO, Yammer firstround.com/review/Responsiveness-New-Efficiency/
  35. 58.

    We’re hiring Ruby developers who want to make amazing products.

    Jeremy Baker jeremy@retailzipline.com @jhubert https://speakerdeck.com/jhubert photos courtesy of unsplash.com