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

Cells refactroing

Cells refactroing

Roman Dubrovsky

September 29, 2016
Tweet

More Decks by Roman Dubrovsky

Other Decks in Programming

Transcript

  1. Summary • Don’t use ‘each’ on views, use for it

    nested cell • Use ‘property’
  2. Summary • Don’t use ‘each’ on views, use for it

    nested cell • Use ‘property’ • Use ‘delegate’
  3. Summary • Don’t use ‘each’ on views, use for it

    nested cell • Use ‘property’ • Use ‘delegate’ • Extend cells instead of code duplication
  4. Summary • Don’t use ‘each’ on views, use for it

    nested cell • Use ‘property’ • Use ‘delegate’ • Extend cells instead of code duplication
  5. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments
  6. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  7. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  8. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  9. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  10. Don’t use object’s interfaces on templates • Use delegates =

    model.field property :field = field Property
  11. Don’t use object’s interfaces on templates • Use delegates =

    model.field property :field = field Property Delegates = object.field delegate :field, to: :object, prefix: true = object_field
  12. Don’t use object’s interfaces on templates • Use delegates •

    Use decorators methods = I18n.l created_at, format: :long def created_at_long_date I18n.l created_at, format: :long end = created_at_long_date
  13. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  14. Logic on templates • Use decorators methods • Don’t use

    iterators on rendering • Don’t use big condition statements, hide it on another templates, cells to methods
  15. Logic on templates • … • Don’t use big condition

    statements, hide it on another templates, cells to methods
  16. Logic on templates • … • Don’t use big condition

    statements, hide it on another templates, cells to methods
  17. Logic on templates • … • Don’t use big condition

    statements, hide it on another templates, cells to methods If statements have a lot of logic, make sense to create cell for it
  18. Logic on templates • … • Don’t use big condition

    statements, hide it on another templates, cells to methods Good idea hide statement on another template and render it on main template
  19. Logic on templates • Use decorators methods • Don’t use

    iterators on rendering • Don’t use big condition statements, hide it on another templates, cells to methods • Don’t use many condition statements or blocks, hide it on templates
  20. Logic on templates • … • Don’t use many condition

    statements or blocks, hide it on templates
  21. Logic on templates • … • Don’t use many condition

    statements or blocks, hide it on templates
  22. Logic on templates • Use decorators methods • Don’t use

    iterators on rendering • Don’t use big condition statements, hide it on another templates, cells to methods • Don’t use many condition statements or blocks, hide it on templates • If having some nesting levels, use templates
  23. Logic on templates • Use decorators methods • Don’t use

    iterators on rendering • Don’t use big condition statements, hide it on another templates, cells to methods • Don’t use many condition statements or blocks, hide it on templates • If having some nesting levels, use templates • Cells only rendering something, don’t calculate results
  24. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  25. Problems on using cells • don’t use object’s interfaces on

    templates • cell’s structure • large number of arguments • many logic on templates • don’t use ‘strftime’
  26. Summary • Use delegates • Use decorators methods • Don’t

    use ‘strftime’ • Don’t use iterators on rendering • Don’t use big condition statements, hide it on another templates, cells to methods
  27. • Don’t use many condition statements or blocks, hide it

    on templates • If having some nesting levels, use templates • Cells only rendering something, don’t calculate results