Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Messy code often begins with a simple "if". Continuing down that path is a road to ruin, but there's a simple way to avoid it. East-oriented Code is an approach that helps you follow Tell, Don't Ask. It guides you away from Feature Envy and toward better encapsulation. See before and after code and walk through easy to repeat steps that will make your Ruby programs better and easier to maintain. Help us caption & translate this video! http://amara.org/v/FixJ/
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 this presentation at RubyConf 2014, Jim Gay discusses the concept of Eastward-oriented Code, which is centered around the programming principle 'Tell, Don’t Ask.' This approach encourages better code organization, while minimizing messy structures that commonly arise from excessive queries within the code. Key themes include: - **Understanding Eastward-oriented Code**: The concept focuses on guiding information flow in a direction metaphorically described as 'eastward' for commands and 'westward' for queries, aiming to simplify code complexity. - **Rules for Implementation**: Gay introduces several rules to follow when writing code: - Always return 'self'. - Allow objects to query themselves, except in the case of factories. - Minimize the use of 'if' statements, as they can lead to excessive complexity. - **Importance of Encapsulation**: Gay emphasizes the need for objects to manage their data display without excessive external querying, thus ensuring that they control their representation. - **A Practical Example**: He uses a class structure for a 'Person' that handles addresses as an illustration, demonstrating how to avoid too many responsibilities within a class object which often leads to bugs and confusion. - **Law of Demeter and Its Application**: The Law of Demeter is mentioned, highlighting the need for objects to interact minimally with others, retaining knowledge only about themselves and their direct interactions. - **Templates and Responsiveness**: Gay suggests utilizing templates for formatting outputs, allowing objects to dictate how their information is represented while adhering to the principles discussed. - **Conclusion and Mastery**: The presentation concludes with an assertion that mastery lies in understanding what objects should control and implementing strategies that foster encapsulation and reduction of unnecessary queries. Overall, Gay invites viewers to reflect on their coding practices and apply these rules to enhance the maintainability and clarity of their Ruby programs.
Suggest modifications
Cancel