models Query object Scopes Public method in model Form-handling code Form object Instance variables Methods, Exposure Class-level common behaviour Modules Complex method Service object Instance-level common behaviour Service object A long inheritance chain Nowhere. Replace with composition Complex strong parameter definitions Permitters Complex conditionals Policy objects View-handling code View objects
models Query object Scopes called everywhere! Make them private accepts_nested_attributes_for Form object AR methods called everywhere! Make them private Class-level common behaviour Modules or Inheritance Complex method Service object Instance-level common behaviour Modules, Inheritance or Service object Outgrown STI Use abstract base classes or Composition attr_accessible Strong Parameters or Permitters Complex conditionals Policy objects View-handling code View objects
Domain logic mixed 1 AR model + one or more domain models Validations with context Form objects Slow callbacks Background job or Messaging Many callbacks Messaging Callbacks talking to other models Messaging Callbacks talking to same model Wherever it is. Good job! :) Observers See callbacks.
Policy objects or View objects Hacks to get forms to work Form objects Many instance variables Partials, Methods, View objects, Templates Many helpers Inherited/Composed View objects Repeated code View objects or partials Ruby code being abused Nowhere. Use stricter templates Many JS variables set/inlined Nowhere. Render JSON Hacks to render HTML from AJAX Nowhere. Render JSON & use a good JS framework Ruby code in JS Nowhere. Render JSON & use a good JS framework
code coverage Write more tests App failing, tests passing Red, Green, Refactor. Remove old tests. Use rspec-fire/minitest-firemock Code without tests Write more tests Logic in view files See previous slide, then write tests. $LIBRARY being tested Stub, Spy Code to be refactored without tests Write black box tests, refactor/rewrite, write unit tests Slow tests Replace factories with plain objects Fixtures Replace with plain objects Slow tests Decouple. Remove test_helper/spec_helper Brittle feature tests Page Object Model
just come and talk to me :) ! Perks: 1. Multi-national startup. 2. ♥ new technologies 3. Great learning environment. 4. Competitive salary 5. Free lunch, a fridge full of food, PF, insurance, and a MacBook Pro/ Thinkpad. 6. Flexible work timings 7. Work remotely 8. We are young, quirky, and seek adventure. Sorta like Bilbo Baggins.