Skip to content
RHY3756547 edited this page May 26, 2017 · 3 revisions

License

The MPL 2.0 is a per-file license, so it is preferred that it is at the start of all code files when possible. This allows individual code files from this project to be used in other works, so long as the license is respected.

/*
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
 * If a copy of the MPL was not distributed with this file, You can obtain one at
 * http://mozilla.org/MPL/2.0/. 
 */

Server-side Programming Approach

While this might not have a place in a document of this kind, it is incredibly important for a project like this.

DO NOT ASSUME INFORMATION SENT FROM CLIENTS IS CORRECT. All data must be verified by the server, and all script execution must be run by the server with the results being sent to the clients. This is to ensure that no cheating can ever occur. If there is one slip-up in the codebase, it is a lot more severe than if it were present in a closed-source project, as it may be a lot easier for attackers to spot.

Style

We typically use the Visual Studio default style in nearly all locations. Typing in VS2015 should automatically format to the desired style. This style is not strict, and can be broken to make code blocks or inline data look "nicer".

When a line of code becomes rather long (typically a Boolean expression), it should be split onto multiple lines. This can lead to some funky layouts, but it can make large run-on conditionals easier to understand, if they are broken up in a meaningful way.

Private/Public/Protected

While there may be some bad examples in the code right now, you should try to keep variable access as private as possible. Preferably, no naming convention is to be used for private members, except if they are hidden by a public accessor.

Accessors

When an accessor hides an internal value that it uses, this value should be private and start with an underscore.

private int _WrappedValue;
public int WrappedValue {
    get {
        return _WrappedValue;
    }
    set {
        //do things
        _WrappedValue = value;
    }
}

We use the short form for properties we only wish to define for use in reflection:

public int ReflectableProperty { get; set; }

(you'll see this a lot in UI code, or primitive operands)