Quote:
Originally Posted by cbk1994
PHP Code:
/*
Variables:
temp.level - current level
temp.size - size of table
*/
Why make the engine do more work by even parsing the text to see if it should do anything with it? Comments work just as well.
|
Because comments like that lack a formal means of writing (as opposed to phpdoc or javadoc) and therefore could be written in varying ways, increasing variations between different coder's scripts.
When trying to say "I'm going to use this variable later", declaring beforehand it is a very natural way to do so, and avoids these inconsistencies.
I really don't think that it is a performance hit to do this during actual runtime as the script is compiled (with a YACC/Bison parser), not interpreted, therefore it would be optimized already.
Also trying to make little performance over-optimizations can lead to very nasty could in general and is a good practice to avoid when there are really no actual benefits to reap.
Quote:
|
It is general Graal style to have classes in all lowercase letters. I don't know of a single server that has classes with uppercase letters. Classes are not objects (like this rule was meant for). There's no reason to capitalize them.
|
Classic's Dev Server does, and the coding was done by other people besides myself.
However, this is a fair point, but I don't see a reason as to not capitalize them besides increasing clarity and distinguishability between classes / objects / weapons.
Also, technically classes can be instantiated as objects with the
import syntax.
Quote:
|
I'm like 99percent certain this is incorrect. Someone please let me know if I'm wrong. return is not a function in any language (with similar syntax to GS2) that I know of (such as Java).
|
I guess we'll have to wait on Stefan for that one since he's probably the only one who actually knows. I recall someone telling me this though.
Quote:
|
I disagree completely. It ruins the general indentation style for different blocks of code. Over-indentation is not a problem. Not indenting only hurts readability.
|
It doesn't break the indentation style of indenting statements inside of a complex statement.
case is part of the structure of the
switch so it does not break the indentation rule.
Also, indentation can surely be a problem when it requires excessive amounts of side-scrolling to read/alter code.
Quote:
|
Why? There are times when it is perfectly okay to fall through.
|
As
Wikipedia states, omitting
break;s is often a big source of bugs and usually the purpose is better achieved using another statement.
This is the reason why languages like C# have started to prevent people from omitting
break;s.
Quote:
|
This is personal preference
|
Quote:
|
This is personal preference.
|
Quote:
|
it's focused way too much on what personal preference
|
This is a coding conventions guide. Its focus is to promote readable and maintainable code. Both of those words are subjective and most of the things stated in the conventions can not be evaluated objectively.
Although many of the things are personal preference, none of them are illogical.
This is the reason I decided to put this on the forums rather than the wiki per say, because many of this things are arguable, and are bound to be argued on. However, until there is an objective ruling on one of these things that clearly puts one above another, I believe it's important to have a
firm stance on one of the options.