[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Comments in code discussion. Do you guys use alot of comments?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 20
Thread images: 2
File: rage6_0.jpg (40 KB, 424x185) Image search: [Google]
rage6_0.jpg
40 KB, 424x185
Comments in code discussion.

Do you guys use alot of comments? I have been a developer for about 7 years now and havent really been a big comment writer. Even when reading other peoples source codes I can just figure it out from reading the code itself.

I should also state I didn't do any college to learn to program I did it on my own time for fun. Now I have been a paid developer for 4 years I think.

How do you guys code? I write more comments than code, detailed, or none at all.

Pic not related
>>
>>54461402
What do you usually program in though?
>>
>>54461402
I usually write down my process of reasoning out the problem in comments and delete most of them after I've solved it. Explicitly listing it what the code should do beforehand makes writing it well easier and helps me think of cases where it should succeed/fail and how it will work. They're not beneficial afterwards though, since by that point its obvious from reading the code how it works.
>>
>>54461402
i  = 0x5f3759df - ( i >> 1 );               // what the fuck? 


Only comments you need
>>
>>54461620
This.
I do a lot or reworking old code from electrical engineers that had no business programming, so anytime I see comments in code it's helpful as thier code is often super unstreamlined.

Personally, I will write out my algorithm in comments and remove them when completed. I also like leaving detailed function summaries on larger functions.

I'm a 2 year program analyst and freelance ecommerce developer w/compsci degree
>>
>>54461617
I use a variety of langauges
Php, python, c#, most web languages, powershell, java, asp.net(really just c#), and a few more.

>>54461620
I can see how this would be a helpful use of comments I may try this a bit to see if it helps me when I get stuck, thanks anon

>>54461679
Why you would ever need to use this I don't think I know, I would guess for address assignment in C++ but my knowledge in that language is little to none.
>>
>>54461740
>mostly web languages
So usually the more clear to read/understand languages? Hence why you don't find the lack of other peoples comments annoying.
C/C++ shit like >>54461679 and what >>54461697 says about EE's (mostly C/C++ I'd guess) really needs comments if you don't know 99% of the language
>>
File: confused tantei.jpg (43 KB, 372x372) Image search: [Google]
confused tantei.jpg
43 KB, 372x372
>>54461402
>I made the magazine longer so it's an automatic
>>
>>54461402
It's nice to have an input/output and brief method description at each function declaration. Also if there's something weird going on a comment is nice. One thing that people have a tendency to do which really grinds my gears is completely useless comments, such as
int a = 5; //declaration and assignment of variable a

or this really popular one
//Declarations of variables used in program
int a,b,c;
float f,g,h;
etc
>>
>>54461402
1 comment for every 6-7 lines of code seems about right to me.
>>
>>54461402
>revolving cylinder
>magazine
>hammer
>bolt
>should thing that goes up

What in the actual fuck is this?
>>
I like to use comments to signpost my code, so I will have comments like
// Load file
~~~ 20 lines ~~~
// Process JSON to array
~~~ 10 more lines ~~~
// Calculate bounding box of element
~~~40 lines~~~
and so on.
More than anything it's for when I'm scrolling up and down and need to get an overview of what's located where, also it doesn't hurt in making the code skimmable, so I can fast scroll down and see what's going on without having to actually read anything in detail.
>>
>>54462172
Probably bad habits from shitty teachers who ding you for every line of code you did NOT comment on.
>>
>>54462334
I used to use a similar approach but I have been spoiled by script bundling with asp.net and just separate everything in different files. This has also transfered into other languages albeit I have to use a lot of namespaces in other languages. I like it because it makes it easier to find exactly what I am looking for.

>>54462062
>>54462237

I just chose a random picture off my phone and that's what I got. I have no idea where it is from or when I downloaded it.
>>
I only comment for very obscure shit, or on occasion if I need to remember to do something at a later date. Or if I'm working with other people who might need to know something.
>>
>>54462393
One of the reasons why I strayed from college classes, the bullshit they require you to do is mundane and a waste of time
>>
>>54464716
>go to shit college
>get shit education
>"college is a waste of time"
>>
if its a segment of macros calling macros and lots of headache inducing bit shiftan ill comment what it does
>>
>>54464744
I mean I stopped college and already had the skill set required to be a developer and I am now. In a year I will be a senior developer, with a expanded skill set of server administration. SCCM, ADFS, IIS, Firewalls, network setup and configuration, wireless controllers and more.

So I didn't see a point continuing in college when I have several degrees worth of knowledge and experience.
>>
>>54464840
thats reasonable
Thread replies: 20
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.