Style guide
Moderator: PPS-Leaders
As of now, I have created a namespace for every subproject (like namespace "weapon" for my little project).
If nobody complains, I'm going to change that and simply create one namespace: orxonox.
And I'm also going to change the styleguide then. But I'll give it a little time...
Oh, there's something else: What is so important about keeping the code size to 80 characters, if almost everyone is using an IDE anyway?
I mean I wouldn't exactly agree to 200 characters, but 120 would be extremely more comfortable.
For instance it is now very common to use full names for variables and functions which makes them quite long. And then for a longer argument list you have to make line breaks and in order to improve readability you indent 2 or 3 tabs. All that within a namespace, function and "if" --> 68 characters left. And in a worst case scenario you can write two or three words per line because the next word is already too long to fit in.
I'm sorry to say that for all those who program with an 80 char console..
If nobody complains, I'm going to change that and simply create one namespace: orxonox.
And I'm also going to change the styleguide then. But I'll give it a little time...
Oh, there's something else: What is so important about keeping the code size to 80 characters, if almost everyone is using an IDE anyway?
I mean I wouldn't exactly agree to 200 characters, but 120 would be extremely more comfortable.
For instance it is now very common to use full names for variables and functions which makes them quite long. And then for a longer argument list you have to make line breaks and in order to improve readability you indent 2 or 3 tabs. All that within a namespace, function and "if" --> 68 characters left. And in a worst case scenario you can write two or three words per line because the next word is already too long to fit in.
I'm sorry to say that for all those who program with an 80 char console..
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
When I was doing the exercises for informatics I, I used to code with vim and the console. And consoles were or are (don't know) limited to 80 characters. Which is why programmers got used to not writing more than 80 chars on one line.beni wrote:Whoever that is...1337 wrote:I'm sorry to say that for all those who program with an 80 char console..
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Yeah I know. I remember my first year where I got minus points in my info exercises when the lines where longer.
What I meant: Who still writes with a console? Nearly everybody has an IDE and those who don't have at least a text editor like kate, kwrite, gedit or something. Even with nano it's possible to write lines longer than 80 characters.
I dunno.. but I don't think that anyone would even notice that, if the code was wider than 80 characters.
What I meant: Who still writes with a console? Nearly everybody has an IDE and those who don't have at least a text editor like kate, kwrite, gedit or something. Even with nano it's possible to write lines longer than 80 characters.
I dunno.. but I don't think that anyone would even notice that, if the code was wider than 80 characters.
"I'm Commander Shepard and this is my favorite forum on the internet."
I expected someone to come up with this line-width-80 question
I know that the code might look crapier and needs more time to format. But there are lots of people that use standard 80char consoles to code. For example I often look at code withvim/emacs in a console conected over ssh, in this case you will never have to worry about resizing your console.
But I know, there is no very strong reason to limit it to 80chars. Decide yourselfs if you want to go with the old fashioned 80 chars. But I suggest to have a line width limit otherwise, people with 24" screens will have a big advantage![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
But I know, there is no very strong reason to limit it to 80chars. Decide yourselfs if you want to go with the old fashioned 80 chars. But I suggest to have a line width limit otherwise, people with 24" screens will have a big advantage
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Since I myself use vim, when I am in need of an editor, I think I'll stick to these 80-chars limit mostly, for instance for all comments. There you have to make line breaks anyway...
What about placing header files in header files?
I have compiled a list with all my class prototypes and called it "orxonox_prequisites". The entries are simply class BaseWeapon; class OrxonoxShip; class BarrelGun; etc.
We only have to make a few of these files and when someone adds a new class, he can edit the right file.
The advantage is, that whenever you want to use object pointers in class declarations (only works for pointers) in header files, eg. BarrelGun *myGun_; or in an argument list of a function, you can simply include the files with all the prototypes.
This way you can save a lot of compile time: Imagine you include "asdf.h" in your *.cc file and asdf itself includes "foo.h" and "bar.h". Now you have to compile 3 header files though you only need one: "asdf.h".
Of course right now this isn't a problem, but when the project grows, compile time grows too.
What do you think?
(This idea by the way, is from the Ogre source code)
What about placing header files in header files?
I have compiled a list with all my class prototypes and called it "orxonox_prequisites". The entries are simply class BaseWeapon; class OrxonoxShip; class BarrelGun; etc.
We only have to make a few of these files and when someone adds a new class, he can edit the right file.
The advantage is, that whenever you want to use object pointers in class declarations (only works for pointers) in header files, eg. BarrelGun *myGun_; or in an argument list of a function, you can simply include the files with all the prototypes.
This way you can save a lot of compile time: Imagine you include "asdf.h" in your *.cc file and asdf itself includes "foo.h" and "bar.h". Now you have to compile 3 header files though you only need one: "asdf.h".
Of course right now this isn't a problem, but when the project grows, compile time grows too.
What do you think?
(This idea by the way, is from the Ogre source code)
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
SO WHAT IS IT NOW?
2, or 4 spaces per tab? We really need to agree to a standard!
The style guide says 2..
2, or 4 spaces per tab? We really need to agree to a standard!
The style guide says 2..
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
I don't care about the 80 char limit. Of course I understand the reason, but 99% of the users don't have a problem with larger lines and that's enough.
@2 or 4 spaces per tab: I can hardly read code with 2 space tabs, that's why I'm using 4 in my code, but it's only a personal preference. Is there a good reason for using 2 spaces?
@2 or 4 spaces per tab: I can hardly read code with 2 space tabs, that's why I'm using 4 in my code, but it's only a personal preference. Is there a good reason for using 2 spaces?
Actually you do, but never mind me saying that...beni wrote:You don't exceed the 80 char limit too quicklyx3n wrote:Is there a good reason for using 2 spaces?
#x3n: I totally agree with you. I once had 3 or 4 spaces as a tab, since it really brings more readability into the code. Anyway, I had to change. So, if I can make things finally compile under VC8, and if I have to edit the WorldEntity, I will adapt your file to 2 tabs
![Wink ;)](./images/smilies/icon_e_wink.gif)
But as of right now, I'm still having trouble (at least one more with the getMouseState()) compiling the project. And I really doubt it will run in the first attempt.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Who is online
Users browsing this forum: No registered users and 49 guests