Originally posted by sicarie
The curley bracket!
Collapse
X
-
-
ok i use the right method of currly braces and comments
the reason i do that is because of the coolest teacher at my high school was sick or figuring out what everyone's code does so she made us comment and indent that way also if we coppied other peoples code she knew we at least understood it cause we had to comment them.Code:if($somthin = 'somthing') { with indented code here;//short same line comments $i++;//easy add and standard counter /* with big jolly multi line comments here about the following code and about the program in general and maybe even some credits as to who helped me write it or if i am posting the script for people to use i put my name on it now the reason i do this with proper indention being important is because python dosen't even use the curly braces just indentation and right now i don't know python but sometime when i am not working and doing classes every night i will lean it, and this summer my friend can teach me some */ }
now if you have looked at my code in the posts you can see i have gotten lazy but this is the methodology i belive in.
eircComment
-
-
Great link! A good way to lose your job or get stuck supporting some POSOriginally posted by sicarieThat's going in my bookmarks, right next to The Daily WTF.Comment
-
Using only i++ can get you in trouble. Due to compiler differences, the i might be incremented at a different time than you intend.
post and pre...in C++ it's normally thought that you apply the incremention in relation to the index in the order that you see it.
For instance:
Some compilers will assign the value of temp at index 1 to test index 0. Upon completion, the variable index would still be 0.Code:int index = 0; test[index] = temp[index++];
Other compilers, especially olders ones, will assign the value of temp at index 1 to test index 0, BUT, on completion, the value of the variable index would be 1 (due to the index++). In these cases, you would have to re-write the code as follows:
There's an article about this on the Web somewhere, sorry i don't have the link at the moment.Code:int index = 0; test[index] = temp[++index]
Using index+=1 is easy, but it's not as clear. From a readability standpoint, using index = index+1 is best.
Note: I personally use index+=1Comment
-
I prefer the way of
if(...)
{
//blah blah blah
}
I'd rather sacrifice a few lines of white space for neatly packaged methods & if statements & the ability to find them easily.
speaking of i++ & index++... anyone heard of ii instead of i++?Comment
-
Perhaps I should explain why:Originally posted by strokenYou should use the prefix-version, ++intIndex. It is faster.
Postfix ++ (i++) needs to copy the object first, then increment the original, then return the copy. You get the overhead of a copy of the object.
Prefix ++ (++i) just needs to increment the object and then return a reference to it. No copy is needed.Comment
-
I prefer:
I like:Code:if (databaseGotUpdated) { updateCount++; clearDisplay(); renderNewTable(); }
- The style of indentation
- camelHumpStyle names rather than with_under_scor es
- ++
- Functions in the style verbAdjectiveNo un() in plain English
What does everyone else think ? ( "what a pedant !" ? )Comment
Comment