Click here to Skip to main content
14,669,189 members
Home » Discussions » Work Issues
   

Work Issues

 
GeneralRe: Of Code and Comments Pin
Eddy Vluggen1-Jul-17 7:34
professionalEddy Vluggen1-Jul-17 7:34 
GeneralRe: Of Code and Comments Pin
I.explore.code1-Jul-17 9:14
MemberI.explore.code1-Jul-17 9:14 
GeneralRe: Of Code and Comments Pin
Eddy Vluggen1-Jul-17 10:05
professionalEddy Vluggen1-Jul-17 10:05 
GeneralRe: Of Code and Comments Pin
I.explore.code1-Jul-17 13:33
MemberI.explore.code1-Jul-17 13:33 
GeneralRe: Of Code and Comments Pin
Eddy Vluggen1-Jul-17 23:27
professionalEddy Vluggen1-Jul-17 23:27 
GeneralRe: Of Code and Comments Pin
I.explore.code2-Jul-17 1:01
MemberI.explore.code2-Jul-17 1:01 
GeneralRe: Of Code and Comments Pin
maze327-Apr-18 4:52
professionalmaze327-Apr-18 4:52 
AnswerRe: Of Code and Comments Pin
imagiro4-Jul-17 21:51
Memberimagiro4-Jul-17 21:51 
We had lots of discussion about this at work too, about how extensively code should be commented, and if at all.

First there is a difference between commenting and documenting code. The latter you probably need to do anyway, at least for public APIs. Besides that, imho some visual indicator on top of each function / class etc makes it easier to navigate through code. So a short block on top of each function can act as kind of a separator (like headlines in normal texts), that allows to quickly see where a function starts. So (meanwhile) I add at least a single line with dashes on top of each function, and find that quite useful.

As for comments, I agree with those people, who say code should be written in a way that comments are not necessary. Means: Use names that say what it is about rather than comments, split complicated constructs into multiple steps, even if it appears less "cool" (functional programming!) etc.

However, there are cases, where comments are a good idea. Not just to explain some parts of the code that are hard to understand, but also to indicate that something might look like a bug or a wired construct, but is actually intended. Like this JS:
const a = parseInt(someString, 10);
if (!(a > 0))...
One might think "Wtf? Why not if (a <= 0)...?", and forget, that the former also takes care of NaN.

So my personal guideline:
  • Write code that doesn't need comments.
  • Comment to avoid misunderstandings.
  • Document your code.

GeneralRe: Of Code and Comments Pin
Ice Diamond21-Sep-17 22:53
professionalIce Diamond21-Sep-17 22:53 
AnswerRe: Of Code and Comments Pin
Richard Deeming5-Jul-17 7:57
mveRichard Deeming5-Jul-17 7:57 
AnswerRe: Of Code and Comments Pin
GuyThiebaut16-Oct-17 0:55
professionalGuyThiebaut16-Oct-17 0:55 
GeneralRe: Of Code and Comments Pin
den2k8816-Oct-17 3:28
professionalden2k8816-Oct-17 3:28 
GeneralRe: Of Code and Comments Pin
GuyThiebaut16-Oct-17 4:04
professionalGuyThiebaut16-Oct-17 4:04 
QuestionHTTP 403 Forbidden Error Pin
shanmugapriya rajendran19-Apr-17 15:10
Membershanmugapriya rajendran19-Apr-17 15:10 
AnswerRe: HTTP 403 Forbidden Error Pin
Vinod Jangle13-Jun-17 4:52
MemberVinod Jangle13-Jun-17 4:52 
QuestionWorking with Google Drive in WPF [Jason Gleim, 6 Mar 2013 ] Pin
Raja Chakraborty19-Apr-17 5:15
MemberRaja Chakraborty19-Apr-17 5:15 
AnswerRe: Working with Google Drive in WPF [Jason Gleim, 6 Mar 2013 ] Pin
ZurdoDev19-Apr-17 5:39
mveZurdoDev19-Apr-17 5:39 
QuestionJob search Pin
aterriba5-Apr-17 11:52
Memberaterriba5-Apr-17 11:52 
JokeRe: Job search Pin
Richard Deeming6-Apr-17 2:08
mveRichard Deeming6-Apr-17 2:08 
AnswerRe: Job search Pin
TheGreatAndPowerfulOz13-Jun-17 6:05
MemberTheGreatAndPowerfulOz13-Jun-17 6:05 
QuestionSoftware Development Agreement Contracts Pin
Member 441122528-Mar-17 4:14
MemberMember 441122528-Mar-17 4:14 
QuestionTrying to break into coding. Pin
Member 1307020219-Mar-17 19:14
MemberMember 1307020219-Mar-17 19:14 
AnswerRe: Trying to break into coding. Pin
Tachyonx22-May-17 6:16
MemberTachyonx22-May-17 6:16 
AnswerRe: Trying to break into coding. Pin
Jim_Snyder19-Sep-17 7:09
professionalJim_Snyder19-Sep-17 7:09 
QuestionWhat's on your professional bucket list? Pin
eschindler16-Mar-17 9:10
Membereschindler16-Mar-17 9:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.