Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

To comment or not to comment, that is the question.

I believe my question may stand out, seeing as google answers, people commenting and books all have different opinions.

I am by far no pro when it comes to programming. I do believe I am a few steps in front of the track I am no following, because I have novice experience in C#, C++ and Java.

However, I am very interested in coding, and generally... the art of creating things. Creating a website, creating a game, etcetera. Just now, I reached the episode where Nick Pettit talks about Organizing CSS with comments. I have bought, and read halfway through, the book named "Clean Code." (I stopped reading, because the examples were too advanced for me. I'm going to re-read through once I am more confident and know more.)

In Clean Code they mention that comments are basically just... In the way. Everything should be named correctly, and frequent refactoring should occur.

What are your thoughts on this? Commenting or not? This is my first post here, by the way, and I have a feeling it won't be the last. :)

3 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

If you spend time reading some source code on Github, you'll find out one interesting fact, the more elite a programmer is, the more thoroughly he documents his codes using comments.

Yep. If there isn't comments then you'll most likely find a doc file if it's a large codebase.

I have both books. I think idea Uncle Bob was trying to get at was: you should write the code so clear that it's read like a book. The names of functions match their function and so on and so forth...But even though I kind of agree I will say that we've now gotten to a point(and this is from a Front End angle) where we have tools that extract comments before something goes to production. I also feel like comments help you remember things in your code and helps others to learn faster. Imagine the web without being able to view source code or comments. Their wouldn't be much progress and we'd be reinventing the wheel too much.

Dom Smith
Dom Smith
3,091 Points

I think this is a interesting topic, I was always taught to comment my code, and I think it is important perhaps to highlight certain aspects which someone may find difficult to understand. But the problem is if/when that code is updated or changed in some way if anything those comments will become confusing for the reader. Hence why I think books like Clean Code promote using correctly named functions etc.

I stumbled upon a blog while searching around if commenting is good or not. This shed some light at the topic for me, as a novice programmer. "Code Tells You How, Comments Tell You Why" is the title of the blog post. There seems to be a lot of fuzz going down in the comment section there, so it doesn't clear up too much, but I feel like he conveys his point well. May I ask what your opinions are on this? agree/disagree? :)

http://blog.codinghorror.com/code-tells-you-how-comments-tell-you-why/

http://blog.codinghorror.com/coding-without-comments/

Dom Smith
Dom Smith
3,091 Points

Definitely going to take a read, i'm a newbie as well and was all for commenting etc until my Lead Developer made the point amount working in large systems with over a 1000 lines of code and going back to update comments? lol as you can imagine I didn't quite know what to say.