Skip to content

Instantly share code, notes, and snippets.

@obliviusm
Last active August 29, 2015 14:26
Show Gist options
  • Save obliviusm/19b86672671b022ef10f to your computer and use it in GitHub Desktop.
Save obliviusm/19b86672671b022ef10f to your computer and use it in GitHub Desktop.
Rails Patterns Notes

Quick notes

Code School - Rails Patterns

Info

Notes

Tidy Views and Beyond with Decorators

Info

article https://robots.thoughtbot.com/tidy-views-and-beyond-with-decorators

Notes

  • decorators
  • draper gem
  • unobstrusive ruby https://robots.thoughtbot.com/unobtrusive-ruby
  • NullObject pattern https://robots.thoughtbot.com/design-patterns-in-the-wild-null-object
  • Tell don’t Ask principle where you should tell an object to do something as opposed to extracting data from it and implementing behavior on the caller code
  • Single Responsability Principle where every object should have only one responsability and it should be encapsulated by one class
  • Open/Closed Principle where each object is open for extension but closed for modification
  • prinsiples - Ruby Science book from thoughtbots
  • nasty callback soup

Rails: Useful Patterns

Info

article http://karolgalanciak.com/blog/2014/09/17/rails-useful-patterns/

Notes

  • Pass form objects as data aggregates to service objects
  • Create flexible service objects with listeners
  • Extract context classes - SimpleDelegator
  • About the form objects - I was asking myself the same question some time ago so I tried both approaches. Probably in 100% cases I regretted putting all the logic in form objects. It was tempting at the beginning to put everything there but the usecases became more complex and form object was responsible for tens of things. Now I always extract business logic to the service objects and form objects are responsible only for aggregating data, validations and writing data to the models and I'm really happy with the code.

Essential JavaScript Namespacing Patterns

Info

article http://addyosmani.com/blog/essential-js-namespacing/

Notes

JavaScript Module Pattern: In-Depth

Info

article http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment