Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Inherited views
When we are using MVC
frameworks only view layer does
not correspond to the OO
principles
What frameworks give us
from the box
• view rendering
• partial rendering
• support of helper methods
Biggest disadvantage of
the view layer
• does not support unit testing
Disadvantages of helpers
• do not allow inheritance
• methods are calling without a receiver
• collision between helpers w...
We can replace helpers to
decorators and improve
presentation logic
Advantages of decorators
• allow inheritance
• allow encapsulation
• friendly for unit testing
• does not mutate decorated...
Decorators has
advantages over helpers
But decorators are not
developed for view layer
View Components
next generation of view layer
Cells
view-model layer
Advantages of ‘cells’
• basically a small MVC stack
• own render engine
• OOP features
• separate presentation from the vi...
Benefits for application
structure
• slim controllers
• clear views
• maintainability
When do we need
such approach?
Cells applicable for
• layouts
• generic views
• complex view logic
• widgets
Simple example
Typical situation
• duplicated views for some UI
part
• each view can render specific
partials
• each partial can build spe...
Every new case expects
change of current condition
state and file structure
Somebody should
maintain this stuff
To avoid this painful we
can use the power of
components
Defining base logic
Defining base partials
Inheriting our component
Customizing our partials
Calling our component
Conclusions
• separated from presentation logic
• easy maintenance
• test coverage
• isolated dependencies
–Valentyn Ostakh
Thanks!
Questions?
Inherited views
Upcoming SlideShare
Loading in …5
×

Inherited views

168 views

Published on

Improvements for view layer

Published in: Software
  • Be the first to comment

  • Be the first to like this

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?

×