Author Topic: Helping people (ppl who post code please read!)  (Read 5072 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
As one of the main aims of this place is to help other programmers learn to code, and I know most people are good at this, if someone asks for help on something it is a really good idea to fully comment and explain what is going on in the program.

I've noticed a few sources of late that could have been better explained.

Over complicated and un commented listings will have the reverse effect.

Cheers :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Helping people (ppl who post code please read!)
« Reply #1 on: April 12, 2007 »
Thats a good point I usually make liberal dose of commentry in my own code (even I could get lost in there) but its easier to understand whats goin on when things are explained in the code itself especially when the person on the other end is learnin a new technique.

Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Helping people (ppl who post code please read!)
« Reply #2 on: April 12, 2007 »
commenting....gross!!! :P

I'll keep this in mind :)
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Helping people (ppl who post code please read!)
« Reply #3 on: April 12, 2007 »
Cool, as long as it doesn't stop anyone helping out and posting code it'll be even better :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Helping people (ppl who post code please read!)
« Reply #4 on: April 12, 2007 »
ill try shockwave but ive tried to comment my code but im just not very good at it half the time my comment just get in the way.

i dont really do tuts most of the time i put code up and say heres a func if its usefull to you then yous it if not then dont.
but i get your point ;)
« Last Edit: April 12, 2007 by ninogenio »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Helping people (ppl who post code please read!)
« Reply #5 on: April 12, 2007 »
Some code is better than no code I guess but what I am trying to say is that it's easy for us to forget how it was at first, I think that you have to allow people to figure out some stuff on thier own but posting a whole listing with no comments or description doesn't really help a lot, in fact it can be demoralising for the person learning and it shows poor programming practice on the part of the person posting the listing.

after all how hard is it to do stuff like this;

OPTION STATIC  : '  FIXED SIZE ARRAYS.
OPTION EXPLICIT : ' ALL VARIABLES MUST BE DEFINED.

Through your program so that people can see the flow of it?

And as well as that, if you wanted to take up programming professionally, most companies will insist that you follow a set format for everything, even code indentation! I'm not advocating anything as anal as that, just if someone asks for help, it doesn't help to give them a listing on it's own, it should be explained.

If you find it hard to comment your listings, it's something you should practice doing. Trust me, it will make your code much more portable so you'll benefit too.

This can apply to most of us at some point I guess, so I will repeat, it's not a serious grumble, just a heads up to help the community as a whole.

Cheers :)

Shockwave ^ Codigos
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Helping people (ppl who post code please read!)
« Reply #6 on: April 12, 2007 »
your right shockwave all the code i post for the purposes of the comunity from now on will be commented as much as possible ;)
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Helping people (ppl who post code please read!)
« Reply #7 on: April 12, 2007 »
Fair point!

Normally the only bits of my code you'll find commented are the bits that didn't work first time and I had to comment it to explain to myself what I as trying to do...

Comments like this are totally useless though
Code: [Select]
/* calculate pi */
int calculate_pi(void)
{
...
}
or
Code: [Select]
int a = 10;
a *= 5; // multiply a by 5
since they don't tell you anything extra.  It's far better to comment algorithms and processes, not the individual instructions.

Jim
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Helping people (ppl who post code please read!)
« Reply #8 on: April 13, 2007 »
Some ppl also tend to give their method, funtions and variables a "speaking name"
instead of extensive commenting ...

For example they do

Code: [Select]
float velocity = 1.0f
instead of

Code: [Select]
float v = 1.0f    // velocity
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Helping people (ppl who post code please read!)
« Reply #9 on: April 19, 2007 »
Just make sure you don't lose the code in among the comments. IMO (even though I'm probably the most guilty of not commenting) indentation is far more important than an abundance of comments and if used with (as jim said) just algorithms and processes can make code easily readable.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Helping people (ppl who post code please read!)
« Reply #10 on: April 19, 2007 »
I dont agree indentation may make programming somewhat more organised but indents do not replace comments. the only people who can make sense of uncommented code are those people that are more experienced in the language in which case they are not the targets for the comments. its the newcommers that stand to gain the most from commentation

Challenge Trophies Won: