Skip to content

Commit

Permalink
Add section about params for private variables
Browse files Browse the repository at this point in the history
  • Loading branch information
thojkooi committed May 14, 2016
1 parent b03138c commit 7027971
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions wiki/development/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,25 @@ Usage of the CBA Macro `PARAM_x` or `BIS_fnc_Param` is deprecated and not allowe
Functions and code blocks that specific a return a value must have a meaningfull return value. If no meaningfull return value, the function should return nil.

### 6.5. Private Variables
All private variables shall make use of the `private` keyword on initalization. When declaring a private variable before initalization, usage of the private array syntax is allowed. All private variables must be either initialized using the private key word, or declared using the private array syntax.
All private variables shall make use of the `private` keyword on initalization. When declaring a private variable before initalization, usage of the private array syntax is allowed. All private variables must be either initialized using the private key word, or declared using the private array syntax. Exceptions to this rule are variables obtained from an array. Note that this may only be down by making use of the `params` command family, as this ensures the variable is declared as private.

Good:
```js
private _myVariable = "hello world";
```

Good:
```js
_myArray params ["_elementOne", "_elementTwo"];
```

Bad:
```js
_elementOne = _myArray select 0;
_elementTwo = _myArray select 1;
```


### 6.6. Lines of Code
Any one function shall contain no more than 250 lines of code, excluding the function header and any includes.

Expand All @@ -404,8 +417,8 @@ Declarations should be at the smallest feasible scope.


Good:
```sqf
if (call FUNC(myCondition) then {
```js
if (call FUNC(myCondition)) then {
private _areAllAboveTen = true; // <- smallest feasable scope

{
Expand Down

0 comments on commit 7027971

Please sign in to comment.