Lou Montana/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Reverted edits by R3vo (talk) to last revision by Lou Montana)
Tag: Rollback
Line 1: Line 1:
[[Category: Sandbox]]
[[Category: Sandbox]]
{{Informative | Future [[Code Best Practices]] page}}
----
[[:Category: Scripting Topics]]
[[:Category: Scripting Topics]]
{{Informative | Future [[Code Best Practices]] page}}
== Best practices ==
 
=== Make it readable ===
 
{{Informative | See [[Code Optimisation#Make it readable|Make it readable]] for the short version!}}
 
** Var names
** Format, indentation, no one-line, spacing, line returns
** Be consistent (space/tab indentation, (camel)casing, [https://en.wikipedia.org/wiki/Indentation_style#K&R_style K&R style] / [https://en.wikipedia.org/wiki/Indentation_style#Allman_style Allman style] indenting)
 
=== Make reusable functions ===


----
;Best practices:
* [[Code Optimisation#Make it readable|Make it readable]]
** var names
** format, indentation, no one-line, spacing, line returns
** Be consistent (space/tab indentation, (camel)casing, K&R / Allman style indenting. See [https://en.wikipedia.org/wiki/Indentation_style#K&R_style Indentation Styles])
* Don't duplicate, make functions
* Don't duplicate, make functions
* prefix your public variables with your tag
 
=== Variables ===
 
* Prefix your public variables with your tag
* PRIVATE (or params) your variables
* PRIVATE (or params) your variables
* Use #define SOME_CONST for constant values instead of variables
* Use sqf commands instead of BIS_fnc_xxxxx if possible


;Also:
=== Code location ===
* don't steal code and pretend it's yours
 
* don't try to obfuscate your code: it's considered rude, especially since you learnt from others
* '''Nothing''' in init box ''but'' [[local]] commands for this specific unit - '''all''' the init boxes are run client-side on client connection
* have fun
* {{Inline code|'''0 {{=}}''' ''myCommand''}} is "useful" only for editor fields that for no apparent reason refuse commands returning a value.
 
 
== Final words ==
 
* Don't steal code and pretend it's yours — be a decent human being.
* Don't try to obfuscate your code: it's considered rude, especially since you learnt from others.
* Have fun!

Revision as of 19:24, 5 September 2019


Category: Scripting Topics

Best practices

Make it readable

See Make it readable for the short version!
    • Var names
    • Format, indentation, no one-line, spacing, line returns
    • Be consistent (space/tab indentation, (camel)casing, K&R style / Allman style indenting)

Make reusable functions

  • Don't duplicate, make functions

Variables

  • Prefix your public variables with your tag
  • PRIVATE (or params) your variables

Code location

  • Nothing in init box but local commands for this specific unit - all the init boxes are run client-side on client connection
  • 0 = myCommand is "useful" only for editor fields that for no apparent reason refuse commands returning a value.


Final words

  • Don't steal code and pretend it's yours — be a decent human being.
  • Don't try to obfuscate your code: it's considered rude, especially since you learnt from others.
  • Have fun!