Skip to content
Paul edited this page Dec 13, 2015 · 5 revisions

In Q OS Code, we try to keep similar standard practices across all files. To help do this, we have made this page to clarify how things should be formatted. Please get permission from @raphydaphy if you want to modify this page because it provides an important definition of how code should be formatted.

If you find code in Q OS that does not comply to these standards, please modify the code if possible and submit a pull-request so your changes are reflected in the master Q OS branch.

If/Else Statements

Normal If/Else statements should be formatted like shown below.

if (thing is true)
{
    // do stuff here
}
else if (other thing is true)
{
    // do other stuff here
}
else
{
    // do random more stuff
}

There are two important things to note in the formatting of these statements. The first important thing to note is that each { and } symbol are written on a separate line, and the words if else if and else are always on their own line with there (arguments).

The other important thing to note in the formatting is that { and } symbols are always used even when there is only one line of code inside that if/else/else if statement.

The reason that we write code like this for if/else/else if statements is to maintain a similar formatting style across all our if/else/else if statements and to allow easy readability of your code.

It is also important to note that these formatting principals for if statement's apply to all statement's such as this. This includes for, while, if, else and else if.

Comments

In Q OS code, any comment, no matter how long, should be formatted like the example below.

// we have a space after the comment symbol '//' before the comment itself
// after each main idea/thought/part of the comment we make a new line
// it is best to try to keep each line the same length for easy readability
// the only reason you would need to use multi line comments is when you
// are trying to just comment out a section of a line of code like below
   
print("This is a /*awesome*/ print statement", 0x0D);
  
// as you can see we need to use a multi line comment because we are targeting
// only a specific part of the line where we want to put our comment block

Also... as a side note: Please leave a space after the commas

as you can see, commenting is just as easy as when using any sort of guides on how your comment should be formatted and if everyone working on Q OS uses the same practices in commenting then the code will be much easier to understand from a quick glance.

Clone this wiki locally