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

Refactoring: Decision making in Rails projects

Refactoring: Decision making in Rails projects

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

Jeremy Baker

January 13, 2017
Tweet

More Decks by Jeremy Baker

Other Decks in Programming

Transcript

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

    energy & motivation. Tom Chi Former Head of Experience - Google X
  2. Refactoring photo by tim marshall Changing how the code is

    written without changing what it does.
  3. 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
  4. 1. Decide a change should be made 2. Pick a

    code smell Steps photo by patrick mcmanaman
  5. 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
  6. 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
  7. 1. Decide a change should be made 2. Pick a

    code smell 3. Remove that code smell Steps photo by patrick mcmanaman
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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/
  13. ... toggle: function (list) { ga( "send", “event", “Interface”, “toggle”,

    “Communication Preview Tasks” ); list.toggleClass('is-expanded'); } ...
  14. There is nothing so useless as doing efficiently that which

    should not be done at all. Peter Drucker Old-School Management Consultant
  15. Is hosting a core competency of ours or value we

    deliver for customers? QUESTION #
  16. • 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
  17. 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
  18. 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
  19. View / Serializer Model Migration Rails Server-Side JS Responses (.js.slim)

    signalvnoise.com/posts/3697-server-generated-javascript-responses
  20. 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
  21. ..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
  22. 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
  23. [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/
  24. We’re hiring Ruby developers who want to make amazing products.

    Jeremy Baker [email protected] @jhubert https://speakerdeck.com/jhubert photos courtesy of unsplash.com