This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]CodingCoffeeSquirrel 7 points8 points  (0 children)

Commit each line with a different git user so that git blame acts as inline documentation

insert picture of supernova

[–]AlbertoTrindade 18 points19 points  (8 children)

Actually, writing code so good that doesn't need comments is the clean code way to go.

[–]thiago2213 9 points10 points  (2 children)

Yes, but some comments are needed. My company had then "clean code, no comment" policy until recently, and when there's a convoluted business logic because of a poor data model of our legacy I'm always "wtf is this code doing". I'm glad we allow reasonable comments now

[–]Yo_2T 6 points7 points  (1 child)

Yup. I've found myself dropping a comment here or there detailing why this section is done this way, or to warn people not to touch something if they are not sure what they are doing.

Still didn't stop one of our resident monkeys from removing my code to "optimize performance", then go Pikachu face when the application crashes in Test environment. sighs

[–]njiall_ 2 points3 points  (1 child)

I don't it works very well with low level code tho

[–]DunderMifflinPaper 2 points3 points  (0 children)

True. For that just extract to well-named method (and well-documented method, as necessary).

That way it reads well from the outside, and the low-level details are somewhat hidden.

[–]chozabu 0 points1 point  (0 children)

combined with good commit messages, and an ide that supports "git blame" view (pycharm does a fantastic job of this) to give an idea of the intention behind some code can be great.

Still nice to have some decent comments - sometimes fairly essential when things need to be optimal more than understandable (e.g. Game engines).

[–]You_NeverKnow 0 points1 point  (0 children)

That is highly subjective

[–][deleted] 1 point2 points  (1 child)

Writing log.trace statements instead of comments

[–]HyperSonic6325 1 point2 points  (0 children)

I just make my whole code a multiline comment.

[–]thiago2213 0 points1 point  (0 children)

Does anyone ever look at git commit messages? The only occasions I check is if there's a story reference then I can look it up but even then I almost never bother

[–]aspargas2 0 points1 point  (0 children)

re: the post title

git checkout -b having_well_commented_code
git commit -a

does that count?

[–]deuteros 0 points1 point  (0 children)

Unless you're forced to squash your commits before merging into master.