Your SlideShare is downloading. ×
0
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Model of the colossus @ Café com Dev
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Model of the colossus @ Café com Dev

584

Published on

Saiba como não deixar seu model virar um ameaçador Colosso. …

Saiba como não deixar seu model virar um ameaçador Colosso.
Vídeo da palestra em https://www.eventials.com/pt-br/helabs/model-of-the-colossus/

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
584
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Model of the Colossus
  • 2. @maurogeorgemaurogeorge.github.comaprenderphp.com.brMauro George
  • 3. Seu model, um grande colosso
  • 4. Mas por que istoacontece?
  • 5. Um pouco de história
  • 6. Rails 15 minutes blogComeçamos bem
  • 7. Começamos bemMVC
  • 8. Começamos bemRails way
  • 9. Começamos bemMigração de outras linguagens direto para o RailsDesde que mude o mindset
  • 10. Inicia a confusão paranovatos2 Stacks
  • 11. Inicia a confusão paranovatos37 Signals stackERB for view templatesMySQL for databasesMiniTest for testingFat Models, Skinny Controllers
  • 12. Inicia a confusão paranovatosPrime stackHaml for view templatesPostgreSQL for databasesRspec/Cucumber for testingSkinny models, controllers, and a service layer
  • 13. AR quebra o SRPAlto acoplamento- Callback- Observer- FindersFalta de coesão- Salva- Envia e-mail- Posta no Facebook
  • 14. Anti-patternModel gerando conteúdo para view
  • 15. SoluçãoDecorator & Presenter
  • 16. SoluçãoDecoratorPara quando lidamos com apenas umaentidade
  • 17. Anti-pattern
  • 18. Soluçãoapp/decorators/user_decorator.rb
  • 19. Solução
  • 20. SoluçãoPresenterPara quando lidamos com N entidades
  • 21. Anti-patternMétodo de Post ou User?
  • 22. Soluçãoapp/presenters/writter_post_presenter.rb
  • 23. Solução
  • 24. SoluçãoPrefira esta abordagem a helpersHelpers são procedurais
  • 25. Anti-patternModel Callbacks
  • 26. Anti-pattern
  • 27. SoluçãoService
  • 28. Soluçãoapp/services/post_notify_users_service.rb
  • 29. Solução
  • 30. Anti-patternModel Salvando N models
  • 31. Anti-pattern
  • 32. SoluçãoForm Object
  • 33. Soluçãolib/active_model/model.rbJá vem no rails 4Gem active_attrGem virtus
  • 34. Soluçãoapp/models/user_with_post.rbModel nem sembre herda de AR
  • 35. Solução
  • 36. ActiveSupport::ConcernsPrefira as abordagem utilizando POROsActiveSupport::Concerns taca tudo paradebaixo dos panos
  • 37. Bad SmellsMeu Model está virando um Colosso?
  • 38. Bad SmellsDiversos métodos com nome de outraentidade
  • 39. Bad SmellsN métodos recebendo o mesmo paramêtro
  • 40. N métodos privados que são usados emapenas um métodoBad Smells
  • 41. Classe gigante(Provavelmente uma God Class)Prefira N classes pequenasBad Smells
  • 42. Pro FuturoDCI
  • 43. Crie classesQuebre Model e Classes grandes emclasses menoresClasses que façam apenas uma coisa bemfeitaConclusão
  • 44. @maurogeorgemaurogeorge.github.comaprenderphp.com.brMauro George
  • 45. Referênciashttp://rubyweekly.com/archive/124.htmlhttp://rubyweekly.com/archive/126.htmlhttp://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-inhttp://mikepackdev.com/blog_posts/31-exhibit-vs-presentersamuelmullen.com/2013/05/the-problem-with-rails-callbackshttp://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/http://rubysource.com/ddd-for-rails-developers-part-1-layered-architecture/http://blog.plataformatec.com.br/2012/03/barebone-models-to-use-with-actionpack-in-rails-4-0/http://www.youtube.com/watch?v=DC-pQPq0acs

×