Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Encapsulating Views by Joel Hawksley Unlike models and controllers, Rails views are not encapsulated. This makes them hard to reason about and difficult to test, leading us to use abstractions such as presenters and decorators. In this talk, we'll explore the inner workings of how Rails compiles and executes views today, the lessons we've learned building encapsulated views at GitHub over the past year, and how you can do the same with the support for 3rd-party component frameworks coming in Rails 6.1. __________ Joel is a software engineer at GitHub. He works on the Design Systems team, leading the development of ViewComponent.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the video "Encapsulating Views," Joel Hawksley discusses the challenges of Rails views, which lack encapsulation, making them difficult to test and reason about. As a software engineer on the Design Systems team at GitHub, Hawksley presents a solution called ViewComponent, which offers a structured way to encapsulate view logic and enable better testing. Key Points Discussed: - **Encapsulation in Rails Views:** Unlike models and controllers, Rails views do not encapsulate data or methods effectively, leading to complexities and testing difficulties. - **Common Abstractions:** To manage complexity, the Rails community has developed several abstractions like decorators, presenters, and React components. However, many developers resort to combining these techniques, which complicates the view structure further. - **Testing Challenges:** Rails does not provide built-in support for unit testing views, forcing developers to rely on more expensive UI tests. This results in slower test execution and increased maintenance overhead. - **Introduction of ViewComponent:** The ViewComponent pattern creates encapsulation at the view level, promoting a cleaner structure. Each component is encapsulated, meaning they don’t share global state, making them easier to test and maintain. - **Community Contributions:** Since its release, ViewComponent has seen vast community support, leading to numerous contributions that improved its functionality, such as adding generator support and introducing content areas for organizing layouts effectively. - **Performance Benefits:** The architecture of ViewComponent significantly reduces runtime compilation overhead by compiling views at application startup, which enhances performance during the first request handling. - **Future of Views:** Hawksley emphasizes a pivot towards utilizing components for all new views within applications, suggesting that components can effectively replace partials, improving encapsulation and consistency across the application. The main takeaway from Hawksley's presentation is that adopting a component-based architecture in Rails allows developers to create more maintainable, testable, and performant view layers. Ultimately, this fosters better development practices and enhances user experience by providing a more robust and organized codebase.
Suggest modifications
Cancel