Why is so much code like this? - page 2

 
pro_: Agree with Raptor. Topic about nothing. I get a lot more frustrated when people post their code here without using SRC. How they code their program is up to them, unless they are going to ask for help.
And if they're going to ask for help.... then which? :P
 

pro_:

Agree with Raptor. Topic about nothing. I get a lot more frustrated when people post their code here without using SRC. How they code their program is up to them, unless they are going to ask for help.

Code formatting conventions is something everyone who codes runs into sooner or later so what is your problem with those who want to discuss it, discussing it ? and who posted code here without using src ?

 
pro_:

Agree with Raptor. Topic about nothing. I get a lot more frustrated when people post their code here without using SRC. How they code their program is up to them, unless they are going to ask for help.


It's not a topic about nothing.

As probably 90%+ times, people who post code ARE asking for help, it makes sense that the format should be easy to follow.

 
GumRai:


It's not a topic about nothing.

As probably 90%+ times, people who post code ARE asking for help, it makes sense that the format should be easy to follow.


A good practice before posting a code may be reformatting it by any of C++ formatter/beautifier, which is often included in simple text editors (notepad++, SciTe, jEdit).
 

As we're on the subject - some code snippets here 'encourage me to write, you can never have too much white space :) a single CR here and there, adds so much for so little effort and filesize...

 
ydrol:

As we're on the subject - some code snippets here 'encourage me to write, you can never have too much white space :) a single CR here and there, adds so much for so little effort and filesize...

+ 1

also white space either side of + - = == * / && || etc. helps when looking for divide by zero issues

 

:) I see I rattled a snake cage here ... Didn't mean to upset you guys. You can discuss anything you like (just don't go into politics, NSA is listening) :))))

As for the "good practice" in writing a code I am all for it, I also have my own style. Actually it differs for different code, depending on whether it is a function within an indicator, script, etc. I think for readablility code should be compact... not splattered all over the page. But that's my preference. I can always tighten up all those spaces, and many lines into a very concise format, and actually do that whenever using other people's code. Should I tell other's how they should be writing their code? of course not.

What I was trying to say before was, while we are discussing the "good practice", people here don't even bother using SRC when posting a code. Why does that happen? Little respect for others, only "give-me,give-me" attitude. And that is frustrating. I think those who ask for help will get to those "good practices" with time, if they start respecting others (with SRC for starters). I hope I made my point clear.

 
pro_:

What I was trying to say before was, while we are discussing the "good practice", people here don't even bother using SRC when posting a code. Why does that happen? Little respect for others, only "give-me,give-me" attitude. And that is frustrating. I think those who ask for help will get to those "good practices" with time, if they start respecting others (with SRC for starters). I hope I made my point clear.

I think new people don't use the SRC button because:

  1. they don't read any posts before posting their own 1st post
  2. there is nothing in the registration/rules asking them to do so

. . . what annoys me is when I ask them to edit their post and they don't . . .


Before you suggest I make a "sticky read this before posting" type post . . . Moderators cannot make posts sticky . . . we have to ask Admin to do that for us

 
GumRai:

It's not a topic about nothing.

As probably 90%+ times, people who post code ARE asking for help, it makes sense that the format should be easy to follow.

I posted the following in another thread just yesterday, and I think it is relevant here too:

There are many coding styles, but the choice of a particular style (or combination of styles) is largely up to the individual programmer. However, I think there are three things that are important. In order of importance (at least in my opinion), they are:

  1. The code must be syntactically and logically correct;
  2. The code should be easily comprehensible by the person(s) who wrote it; and
  3. The code should be easy to read by people who didn't write it.
The first two are critically important. The third may not be as important as the previous two, but it helps allot when the programmer shows his/her code to others--for example, when he/she posts code here and asks for help finding a syntax or logic error.

 
Thirteen:


The first two are critically important. The third may not be as important as the previous two, but it helps allot when the programmer shows his/her code to others--for example, when he/she posts code here and asks for help finding a syntax or logic error.

But doesn't that mean that if they are asking for help with syntax or logic the code isn't going to " . . be syntactically and logically correct;" ?


One thing nobody has mentioned yet . . . // comments

I often write pseudo code in comments in my code before I actually write any code, it helps me keep focus on how I was planning to solve the problem the code is meant to address, it also serves as a reminder of why I did what I did when I come back to the code weeks/months/years later.


Comments also massively help other people, if at the top of a function you explain what the function is meant to do, what the inputs are what the outputs are and how you get from one to the other then it is much easier for anyone trying to help . . . it's not easy trying to figure out what code is meant to do if the code is broken in the first place, comments help in this situation.

Reason: