I like the second, declarative structure. I also prefer that we don’t create something only to immediately mutate it.
Perhaps you could move the conditional into the add_comment_data method as a guard? Then you wouldn’t have the conditional in the hash construction.
Small point, but I prefer methods named after what they return, rather than what they do. So could kill the add_ prefix from the methods. I find this generally helps me to think in a more ‘OO’ mindset.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like the second, declarative structure. I also prefer that we don’t create something only to immediately mutate it.
Perhaps you could move the conditional into the
add_comment_data
method as a guard? Then you wouldn’t have the conditional in the hash construction.Small point, but I prefer methods named after what they return, rather than what they do. So could kill the
add_
prefix from the methods. I find this generally helps me to think in a more ‘OO’ mindset.