Successfully reported this slideshow.

Inherited views

0

Share

Loading in …3
×
1 of 29
1 of 29

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Inherited views

  1. 1. Inherited views
  2. 2. When we are using MVC frameworks only view layer does not correspond to the OO principles
  3. 3. What frameworks give us from the box • view rendering • partial rendering • support of helper methods
  4. 4. Biggest disadvantage of the view layer • does not support unit testing
  5. 5. Disadvantages of helpers • do not allow inheritance • methods are calling without a receiver • collision between helpers with similar methods
  6. 6. We can replace helpers to decorators and improve presentation logic
  7. 7. Advantages of decorators • allow inheritance • allow encapsulation • friendly for unit testing • does not mutate decorated object • does not change the behavior of decorated object
  8. 8. Decorators has advantages over helpers
  9. 9. But decorators are not developed for view layer
  10. 10. View Components next generation of view layer
  11. 11. Cells view-model layer
  12. 12. Advantages of ‘cells’ • basically a small MVC stack • own render engine • OOP features • separate presentation from the view logic
  13. 13. Benefits for application structure • slim controllers • clear views • maintainability
  14. 14. When do we need such approach?
  15. 15. Cells applicable for • layouts • generic views • complex view logic • widgets
  16. 16. Simple example
  17. 17. Typical situation • duplicated views for some UI part • each view can render specific partials • each partial can build specific content
  18. 18. Every new case expects change of current condition state and file structure
  19. 19. Somebody should maintain this stuff
  20. 20. To avoid this painful we can use the power of components
  21. 21. Defining base logic
  22. 22. Defining base partials
  23. 23. Inheriting our component
  24. 24. Customizing our partials
  25. 25. Calling our component
  26. 26. Conclusions • separated from presentation logic • easy maintenance • test coverage • isolated dependencies
  27. 27. –Valentyn Ostakh Thanks!
  28. 28. Questions?

×