Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RubyConf 2019 - The Singleton Module and Its Pattern In Ruby by Mike Calhoun The singleton design pattern allows for the creation of an object that is restricted to one single instance. No matter how big or complex your application is, there will only ever be one. This has caused some controversy about the quality and maintainability of code that leverages it. Yet, Ruby’s standard library contains a module that implements this pattern. Let’s take a closer look at this module and the “controversy” around its implemented pattern. Let’s also consider singletons in Ruby and the purpose they serve for the language in general. #rubyconf2019 #confreaks
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 talk titled 'The Singleton Module and Its Pattern In Ruby,' Mike Calhoun presents an in-depth exploration of the Singleton design pattern, particularly its implementation in Ruby through the Singleton module. Key points of the talk include: - **Introduction to Singly Instances**: The Singleton pattern ensures that a class has only one instance and provides a global access point to that instance. Unlike global variables, Singleton instances do not occupy global namespace and are not instantiated until explicitly called. - **Controversies Around Singletons**: Calhoun discusses the mixed opinions within the programming community regarding Singletons. Critics highlight issues such as tight coupling, potential for mutable shared state, and challenges with testability due to global accessibility. - **Applications of Singletons**: While Singletons are often associated with problematic practices, there are valid use cases, such as logging and configuration management, where single global instances work effectively and offer a consistent state. - **Ruby's Singleton Module**: The talk introduces Ruby's Singleton module (`singleton.rb`), which ensures a single instance by privatizing methods like `new` and `allocate`. The module also prevents cloning to maintain the uniqueness of the instance. - **Practical Examples**: Calhoun shares practical examples using a sample class called 'SingletonExample,' demonstrating how to correctly instantiate a Singleton and observe its object identity in Ruby. He also touches on the Singleton class's utilization within Ruby's object model, showcasing its significance for encapsulation and method definition. - **Insights from the Talk**: Concluding the talk, Calhoun emphasizes that while Singletons can be misused, understanding their structure and context is vital. Proper use cases can enhance programming efficiency, particularly in situations with a unidirectional flow of data. The presentation wraps up by inviting attendees to reconsider how Singleton patterns can be effectively integrated into Ruby applications, fostering a deeper understanding within the developer community about design patterns, object modeling, and best practices.
Suggest modifications
Cancel