Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Extremely Defensive Coding by Sam Phippen Defensive programming is one of those abstract ideas that seems great but is often unclear in practice. In this talk we'll look at some of the extremely defensive patterns that have been driven out in RSpec through the years. We'll look at building Ruby that works across a range of interpreters (including 1.8.7!). We'll investigate how you can write code that defends against objects that redefine methods like send, method and is_a?. You should come to this talk if you want to learn about method resolution in Ruby, and cross interpreter design patterns. Help us caption & translate this video! http://amara.org/v/H1T7/
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 RubyConf 2015 talk "Extremely Defensive Coding," speaker Sam Phippen discusses the principles of defensive programming specifically tailored for Ruby development, with a focus on techniques implemented in the RSpec framework. - **Introduction to Defensive Programming**: Phippen defines defensive programming as an essential concept that helps developers write resilient code, particularly in Ruby, a language prone to dynamic changes by users. - **Importance of Experience**: He highlights the significance of community interaction and feedback, noting his role in the RSpec core team, and expresses that newcomers to Ruby and Rails contribute to the vitality of the programming community. - **Method Overriding Concerns**: Phippen shares an anecdote about a challenging question posed by a junior developer regarding overriding methods on the Ruby Object class. He concludes that overriding methods should strive for consistency with Ruby's expected behaviors rather than introducing inconsistencies. - **Criteria for Good Gems**: He outlines several criteria that define a good gem, emphasizing the importance of a user-friendly interface that simplifies developers' tasks while being functional across various Ruby interpreters. The complexity of a gem's internal workings is deemed less critical compared to how well it integrates with applications. - **RSpec Feature Evaluation**: Utilizing RSpec stubbing as an example, Phippen discusses the feature that allows users to replace methods temporarily during tests while ensuring the original methods can be restored post-execution. This is illustrated with a practical example of the `allow` method in RSpec. - **Handling Method Redefinitions in Ruby**: He addresses challenges presented by users who redefine core methods, affecting how the RSpec framework handles method availability. He outlines the strategy of utilizing 'trust but verify,' leveraging Ruby's inherent method capabilities to manage these risks effectively. - **Compatibility Across Interpreters**: Phippen stresses the need for RSpec to be compatible with multiple Ruby interpreters, detailing the specific challenges faced with each interpreter's unique characteristics, especially concerning method retrieval on user-defined objects. - **Conclusion**: He concludes that defensive programming is vital in ensuring a gem can withstand unforeseen user behaviors while maintaining reliability across different Ruby platforms. Phippen reiterates the importance of good design in balancing simplicity with complexity, urging developers to consider these trade-offs when choosing libraries for their applications. He invites the audience to ask questions, further engaging them in the topic.
Suggest modifications
Cancel