Skip to content

Styleguide

Adrian L Lange edited this page May 25, 2020 · 2 revisions

oUF Code Styleguide

  • Readability above all
    • Use whitespace generously
    • Descriptive variable and function names
  • Tabs, not spaces
    • With the exception of in documentation
  • Local functions should be defined as local function foo() end
  • Local functions should be named in "mixed case"
    • e.g oneTwoThree
    • With the exception of in elements where they should be named alike global functions
  • Global functions (methods) should be named in "pascal case"
    • e.g OneTwoThree
  • Constants should be named in all uppercase
  • Blizzard-provided constants used should be upvalued and contain fallback values
  • Local references to global API (upvalues) should be named the same as the original
    • With the exception of libraries, e.g math.abs becomes math_abs
  • Use single quotes (') for strings
    • With the exception in XML files where double quotes (") should be used
  • Call libraries by the library reference, e.g string.match('foo', 'bar')
    • With the exception of on variables, e.g foo:match('bar')
  • Multiline comment should use --, as --[[ ]] is reserved for documentation
  • Define local variables for table references when referring more than twice
Clone this wiki locally