Hello There, Guest! Login or Register


Code Policy
#1
Dear Developers,

When working in a team, the coding styling is very important. At the moment we are not really working as a team, everyone uses their own style of coding, it's just some individuals working on the same code. This is something we must improve.
Some things we are going to want to change is the style in which we code. We no longer want everyone to use their own style, but we will use one style. This allows everyone to read code someone else has written easily, which is very important when you work with a team. An example of coding styles can be found here http://en.wikipedia.org/wiki/Indent_style. Also, Wesley already wrote something some time ago which you may find useful, it can be found here http://trac.sa-mp.nl/lvp/wiki/Guidelines. You can post your opinion, and your favourite coding style, which of course can be a combination of several styles.

We’d also like our gamemode being better documented, which will help everyone understand the code better. We would like your opinion on what should be documented inside the gamemode. There will be a topic about outside documentation, on the wiki, later on. But now you can post on in-source documentation. What should be documented in the gamemode, and on what way? Should we document every check, every variable?
These are just some things that Wesley and me have discussed, but we also want to know what you think. What do you think would help us improve the coding inside our team? What do you think of the things we have thought of? Please let us know. And please don't wait too long, we'd like to have your response within a week so we can write a policy describing the things we have agreed on on this area. After this we will post this document and allow for more comments if necesarry.

Thanks for reading,
Wesley Lancel
Joppe 'Fireburn' Arnold
#2
Hai,

I don't have much time now, so I'll post more soonish. I agree about the writing styles, it seems everybody uses their own style. The wiki link is down btw, and I forgot my pass/username @ trac so I can't read the guidelines either D:.

(I'll post more later, have to go now)

Matthias
#3
I indent the way shown, and maybe add a little of my liking, but it's pretty much the same and easy to read. Also, a note about commenting, don't comment on what it's doing, but why it's doing.
#4
I indent Allman style (bsd in Emacs).
#5
I indent the same as Matthias.

But there is one thing that annoys me and I don't like, spaces in between brackets.

Code:
if (  strcmp ( szPlayerChatMsg1, szPlayerChatMsg2) )
{
    doSomething( );
}


I've noticed Peter Wesley and Pugwipe script like that. I prefer it without the spaces.

Code:
if(strcmp(szPlayerChatMsg1, szPlayerChatMsg2))
{
    doSomething();
}





#6
I prefer the spaces as it makes the code more clear. I've also changed some things in the Guidelines document on Trac, after some comments we received. The indentation style has slightly been altered and the table with Hungarian notations has also been changed.
#7
I don't like spaces either :+. How will the style we use be decided? Check what style is used the most?
#8
That is one factor in deciding indeed, it has to be clearly readable though, and in my opinion some spaces are necesarry. Jay's example is a little over the top,  but the small example that is on Trac only has a few spaces though it looks a lot clearer in my opinion.
#9
Code:
if ( strcmp( szPlayerChatMsg1, szPlayerChatMsg2 ) )
{
    doSomething();
}

This is how I should do it. The spaces around function calls and parameters are primarily used to separate nested stuff a bit more clearly. If there is no parameter in the function call, no spaces are needed.
This is just personal preference, but we need to agree on a specific coding form which shall be used by every single developer.
#10
Code:
if (strcmp (szPlayerChatMsg1, szPlayerChatMsg2))
{
    doSomething ();
}

I like to do it that way.