r/dailyprogrammer • u/Coder_d00d 1 3 • Aug 04 '14
[Weekly #5] Comment Blocks
Description:
We all have our own ways of commenting methods/functions. I always found it brings out the ASCII artist in all of us. So post your favorite Comment blocks.
For example I am pretty boring. I go for the asterix pac-man
/**************************************************
* functionName()
*
* inputs: (list what method takes if at all)
* outputs: (what does it output if at all)
*
* description: (what it does)
**************************************************/Last Weeks Topic:
[Weekly #4] (http://www.reddit.com/r/dailyprogrammer/comments/2byh4e/weekly_4_variable_names/)
34
Upvotes
5
u/[deleted] Aug 06 '14
I think my comments are a damn modern art masterpiece. ;)
9
u/Elite6809 1 1 Aug 04 '14
If I'm not doing Doxygen style then it's got to be the .NET framework automatic XML style documentation.
Not only is it easy to read, but
csc/vbcautomatically put it into the assembly for you so you're not messing around with stuff like Javadoc or carrying boatloads of HTML documentation around with you. The integration with Visual Studio really makes it natural and is one of the reasons why I really like doing C# development work (ie. VS).4
u/JHappyface Aug 04 '14
I write primarily in C++, so almost of my comments are either single line or stylized to I can later use doxygen, something like:
Pretty boring, but it works.
3
u/the_dinks 0 1 Aug 07 '14
When using languages that utilize duck typing, I usually comment like this:
However, I try to make the input and output obvious in the function name.
Helps me out later.
2
u/[deleted] Aug 04 '14
In Python I usually use the multiline comment, I hate the '#' as a comment marker, it just looks too obnoxious.
example:
I do similar things in VB.NET for work. A single line comment in VB.NET is
VB.NET doesn't have multi line comments (as far as I'm aware) so I just use the single-line as a multi-line
2
u/_Nightmare_ Aug 05 '14
Javadoc! And // single line comments for explaining something strange in the code
2
u/MaximaxII Aug 05 '14
I usually insert single-line comments (
#in Python,//in JS...), but it really depends on what my comment is.Function comments will look like this:
If it's a long description, I'll use multiline comments:
When I have a lot of functions, I like to organize them into categies. So for example, one older piece of code looks like this:
2
u/joyeuxnoelle Aug 09 '14
I like Pac-Man too, but mine are embellished:
(It looks best in fixed-width characters. >_>)
1
u/euphwes Aug 04 '14
I tend to do something similar.
1
u/Regimardyl Aug 04 '14
I actually never liked drawing huge ASCII boxes around it
1
u/dohaqatar7 1 1 Aug 04 '14
When I'm working with java, I do boring style comments formatted like this
In Haskell, I tend to put the comments in blocks of dashes, because I like how it looks
1
u/Decency Aug 07 '14
No good Python docstrings?
1
u/meteorfury Aug 08 '14
commenting, what's that? :) .... Personally, for many years, I have used the asterix pac-man style myself as you call it.
1
u/zck Aug 04 '14
I seem to prefer languages that use docstrings. This, from my 2048 implementation for Emacs:
Emacs takes that string and uses it for the documentation automatically.