I've given the idea of coding standards some thought, and here's whats worked for me. I'm not really into the Java naming conventions.
1. Class names are capitilised. eg class TheClass.
2. Method names are capitalised as well. eg. TheClass::TheMethod() {}
3. Attributes are first letter lowercase. eg. int theAttribute;
4. enum items and defines are full uppercase. eg
#define THE_DEFINE 1234
enum TheEnum { ITEM 1, ITEM 2};
5. I dont use hungarian notation anymore (except when I am mandated to by an employer). I find it makes it harder if you need to re-type a variable.
The exception to this is method parameters where the the parameter is the same as a class attribute.
eg.
TheClass::TheMethod(int aParam)
{
param = aParam;
}
6. Inline brackets. There's apparently a NASA study on this, that it reduces the defect count. I havent seen it, and dont know where to find it though.
eg.
if (a)
{
}
Personally I find this easier to read than:
if (a) {
}
Please comment on these styles. If anyone finds them objectionable please say so, and we'll reach a compromise.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Excellent. I was hoping no-one would object to inline braces. :-)
Something I didnt mention yesterday [it doesnt have to be in a coding standard, though I might mention it] is that I also like the reasonable use of whitespace to break the code up. Why developers pack all their code together beats me. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No issues on this front. I think we should document these conventions and keep it. Whenever, we have an issue an informal mail among us should sort it out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've given the idea of coding standards some thought, and here's whats worked for me. I'm not really into the Java naming conventions.
1. Class names are capitilised. eg class TheClass.
2. Method names are capitalised as well. eg. TheClass::TheMethod() {}
3. Attributes are first letter lowercase. eg. int theAttribute;
4. enum items and defines are full uppercase. eg
#define THE_DEFINE 1234
enum TheEnum { ITEM 1, ITEM 2};
5. I dont use hungarian notation anymore (except when I am mandated to by an employer). I find it makes it harder if you need to re-type a variable.
The exception to this is method parameters where the the parameter is the same as a class attribute.
eg.
TheClass::TheMethod(int aParam)
{
param = aParam;
}
6. Inline brackets. There's apparently a NASA study on this, that it reduces the defect count. I havent seen it, and dont know where to find it though.
eg.
if (a)
{
}
Personally I find this easier to read than:
if (a) {
}
Please comment on these styles. If anyone finds them objectionable please say so, and we'll reach a compromise.
I dislike this style of backets:
if (iWantToSaveAnExtraLine) {
putYouHandsInTheAir();
} else {
andWaveEmLikeYouJustDont();
}
Inline brackets are better:
if (thisHasBeenSaidAlready)
{
thenIAgree();
}
Aside from that, I will happily go along with whatever convention is agreed - though I do agree one should be made and stuck to.
Excellent. I was hoping no-one would object to inline braces. :-)
Something I didnt mention yesterday [it doesnt have to be in a coding standard, though I might mention it] is that I also like the reasonable use of whitespace to break the code up. Why developers pack all their code together beats me. :-)
No issues on this front. I think we should document these conventions and keep it. Whenever, we have an issue an informal mail among us should sort it out.
Good one. I'll get a document written up tonight.