DEV Community

Discussion on: Which is more readable?

Collapse
 
sjmog profile image
Sam Morgan

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.