r/rails • • May 14 '14

Commenting My Code -- Best Practices?

I used to comment extensively when I worked in Java, but have fallen into the bad habit of commenting less in Rails. In Java, I had a standardized way of commenting every class/method/program that I learned from my teachers, but never had the same experience in Ruby/Rails, and my comments have been fairly haphazard.

I'm looking to clean up my practices and fully comment the app I'm working on so that it'll be more legible to other people. My questions to you all:

  • What are your commenting best practices?

  • Are there standardized ways of commenting a model, a controller, etc?

  • How much do you dev-comment your views?

  • Got any links to excellent commenting?

BONUS: Where does RDoc figure into all of this? Is it a replacement for commenting your methods, classes, etc? How does it fit into your workflow? I guess I'm just not fully understanding it.

4 Upvotes

31 comments sorted by

View all comments

Show parent comments

0

u/[deleted] May 15 '14

[deleted]

1

u/th12eat May 15 '14

I appreciate the last part completely! Trust me, I know. It's hard to get a free critique (that doesn't reduce your reputation within your workplace/academic institution).

I see your point. I thought of my example in the context of 'can', not 'should'. As in, "In some cases, I can use eql? instead of == to get the same result and be more readable" as opposed to "I should use eql? instead of == to get the same result and be more readable". Regardless, noted.