Coding Convention
All great projects have coding conventions to maintain beautiful and readable codes. And so we do. Our convention helps us to read and understand the code in every files which are included in GNOME Split. If you want to write a patch to improve the program or fix bug, you have to follow our coding convention or your patch will be rejected.
Indent the code
- The code shoudl be indented using 4 spaces and no tabs. It helps text editors to render the code in the same way for everyone.
Classes names
- Start with a upper-case letter
- Camel case, no underscores
- (eg, GnomeSplit)
Methods and variables names
- Start with a lower-case letter
- Camel case, no underscores
- (eg, defaultAlgorithm)
Code style
And finally, here some code, so you'll be able to understand how do we write our code.
public class AnExampleClass implements Runnable { private int count; public AnExampleClass() { count = 10; } @Override public void run() { for (int i = 0; i < 10; i++) { this.doStuff(); } if (count < 5) { this.doStuff(); } else { this.doOtherStuff(); } switch (count) { case 0: break; case 2: this.doStuff(); break; default: this.doOtherStuff(); break; } } /** * Entry point. */ public static void main(String[] args) { AnExampleClass ex = new AnExampleClass(); Thread thread = new Thread(ex); // Start a thread thread.start(); System.exit(0); } }
