Refactoring, Part Two: In Defense of Magic

19-Aug-2021 1168
In my last post, I refactored the status field for cards in my project tracker to a more object-oriented representation that used value objects and classes to replace conditionals throughout the code.I was apprehensive about posting it, because it seems like that kind of OO code is out of fashion. What feedback I got, though, was positive. So I’m going to go a little farther into metaprogramming with this example. The code here works for this project, but eventually goes beyond what I’d be likely to recommend for most projects.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle