Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RailsConf 2019 - Refactoring Live: Primitive Obsession by James Dabbs _______________________________________________________________________________________________ Cloud 66 - Pain Free Rails Deployments Cloud 66 for Rails acts like your in-house DevOps team to build, deploy and maintain your Rails applications on any cloud or server. Get $100 Cloud 66 Free Credits with the code: RailsConf-19 ($100 Cloud 66 Free Credits, for the new user only, valid till 31st December 2019) Link to the website: https://cloud66.com/rails?utm_source=-&utm_medium=-&utm_campaign=RailsConf19 Link to sign up: https://app.cloud66.com/users/sign_in?utm_source=-&utm_medium=-&utm_campaign=RailsConf19 _______________________________________________________________________________________________ Let's roll up our sleeves and clean up some smelly code. In this session, we'll dig in to Primitive Obsession - what happens when our domain logic is all wrapped up in primitive data types? And most importantly, how do we untangle it? #railsconf #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 the video "Refactoring Live: Primitive Obsession" presented at RailsConf 2019, James Dabbs discusses the importance of refactoring code to avoid primitive obsession, which refers to the practice of using primitive data types to represent business objects. The session focuses on real coding practices aimed at simplifying and enhancing code structures in Ruby on Rails applications. Dabbs emphasizes that effective refactoring should not alter the observable behavior of the system but should aim to make the code more understandable and maintainable. Key points discussed include: - **Definition of Refactoring**: Refactoring involves changing the internal structure of software to make it easier to understand and modify without changing its external behavior. - **Primitive Obsession**: This is identified as the tendency to use primitive types like strings to represent complex domain concepts, thereby limiting the expressiveness and usability of the code. - **Approach to Refactoring**: - Begin by identifying code smells related to primitive obsession. - Use specific refactoring recipes, such as replacing primitives with objects and employing polymorphism to enhance code flexibility. - **Example Implementation**: - Dabbs demonstrates this by live coding a Rails application managing student records, where he refactors how grades are represented. Initially, grades were treated as strings, leading to incorrect logic when handling letter grades like C+ or B+. - He illustrates the development process, transitioning to a proper Grade class to encapsulate the logic relevant to grading, making comparisons easier and more accurate. - **Iterative Refactoring**: The live coding segment highlights a step-by-step approach to refactoring, ensuring that tests are run frequently to maintain code integrity and prevent regressions throughout the changes. - **Final Takeaways**: - The session concludes by encouraging developers to integrate refactoring into their daily practices to prevent technical debt accumulation. - Development should harmonize with business requirements—refactoring is essential anytime a new feature requires changes to existing code, and it should be a continuous process rather than an afterthought.
Suggest modifications
Cancel