-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coding standards #554
Comments
Totally agree with this. It's a good way to make the code more readable. I'll also suggest some blank lines and a starting comment on what are we trying to acomplish withing a block: Something like this:
Also, for the record, I prefer 3 spaces instead of 4 for indentation, but is just a number in the tab substitution. |
Also totally agree with Lekensteyn. Including 4 spaces for indentation. And please when every one will be ok, let me correct actual code this way, I have a great idea on how to make it very fast. And as I am maniac, I will really enjoy it :P |
sed? :p Wiki created: https://github.com/MrMEEE/bumblebee/wiki/Coding-Standards
or must it be:
or even:
Another thing, I've always tried to keep the lines within 80 characters unless it became unreadable or such. Your opinions? |
A friend of mine also do that. Originally, this is for printing purposes using vim. But we can use it as a standard for readability. For local, both first and second are convenient for me. So I let the others choose. And no, not sed, as I'm newby to the Linux world and don't now what are the "basics". I would to that using N++ under windows. |
For variables I'd prefer the second or third options for readability. For line lengths I always put one line per statement except in really short 'if' statements:
That will always keep the lines under 80 chars unless some very large expression. In such cases a temporary variable would become in handy to break the function in smaller pieces. |
So let's use the second for variables. |
Included the 80 char limit, |
Yes you can, I will do the same. |
Just to be clear. Are you going to use a tab ( 4 spaces wide ) or are you going to use 4 spaces as indent? I hope you are not even thinking about the last option.....It really s*cks when trying to indent a selected block of text with [shift]--tab. And it is a great idea to implement a standard. In our company we implemented it about 20 years ago. It is much easier for every one to read / understand the code and add some new stuff. One of our best rules: Keep the code spacy, use A LOT of spaces in your lines and please try to add some comments. main(int c,char*_v){return!m(v[1],v[2]);}m(char_s,char_t){return_t-42?_s?63==_t|_s==_t&&m(s+1,t+1):!_t:m(s,t+1)||_s&&m(s+1,t);} ( for the sed command this is almost impossible to live by, sorry about that :-) ) |
In fact we were going to use 4 spaces, not a tab. Because you say that a tab is 4 spaces, but that is almost false, the tab size or even encoding is system-related and even sometimes editor-related. Not the space. |
4 spaces was just an example for the size. Everybody can choose his own indent size when using tabs. Mine is 4 spaces wide. Somebody else can use 2 space wide tabs. It really does not matter what the other guy/girl is using as ident width. |
How do you set the tab size ? And for information, when I edit something under Windows and use tab for indentation, they are replaced by 2 tabs under Linux... |
In Windows: Linux: |
Ok !! I wasn't using one of this programs but I found the equivalent. I've just realized I had never look at gedit options... But as Lekensteyn said, there is an option that should help you : And I confirm it works with MAJ-Tab. |
Yes I know. They are going to all lengths to use spaces as tabs. Just WTF.... |
Most modern editors allow for transparent removal of indentation, so that pressing backspace takes four spaces indention away. Have your considered the other points in the standard? It's not limited to indention. I've used tabs a while a go, but switched to spaces to get consistent display in different programs (editors, browser, printing) |
I normally (for C,C++) use this syntax:
We do not allow people to use the short forms like this
because it can lead to bugs when people are adding code too fast and try this:
instead of
Putting the { and } both on the indent line will also make it more readable and define the block better. And I really like spaces :-) so this:
should be:
|
And does not render spaces. But I can view the raw data of your post, and I agree with everything you've said in it. Including "I really like spaces". If you really like them, why don't you use them as tabulation ? :P |
Because the "old" editors I used did not have the space replace options......And if you want to indent files with that kind of editor, please be my guest. Especially when the files are very large... |
Another syntax I am not going to recommend: putting the ';' on position 80 to mark the end of the lineprinters reach. Code beyond the 80 would not be printed and could not be seen when using the MSDOS debugger. :-) |
@ximi: github uses Markdown which was designed to be easy. Use four leading spaces to start a code block or use three backticks like:
I don't mind using tabs instead of spaces, as long as everyone sticks to it and do not mix those up. My editor shows a line in the background for the X characters limit ;) (with X defaults to 80) |
@Ximi1970 : we're not putting a ; on position 80, just going to the next line if able. |
Just joking :-) |
@Lekensteyn: Thanks for the info, case of RTFM Ximi1970. Never have time for reading manuals :-) Yes that is the most important part: do not mix styles. |
Should be a good idea to say something about Commit messages (as they are part of coding): Should be a line with the idea involving the present change, a blank line and then some more in-depth explanation on the change (not a bible, but some hint to others) so we don't have to diff every file. Unless, of course the change is little and obvious. A really bad commit message:
A good one:
|
I second that, the commit message should be clear and useful. Consider http://stackoverflow.com/q/43598/427545 Keep the commit message within 72 characters, split over lines if necessary.
Note the use of The PPA changelog needs some work too, not just "based on changes XXX", but:
|
Ok, will try to do that from now. |
Some further notice about coding:
|
Let's establish some coding standards as the current code base is getting horrific.
The current proposal is visible at:
https://github.com/MrMEEE/bumblebee/wiki/Coding-Standards
Please discuss before changing.
The text was updated successfully, but these errors were encountered: