Wiki

Clone wiki

PureWork / Coding guidelines

This coding conventions are a set of guidelines for a PureWork that recommend programming style, practices and methods for each aspect of a piece code written for the framework.

It shouldn't be hard to understand. Therefore just have a look at the example code:

#!purebasic

; /**
;  * [FILE HEADER HERE: https://bitbucket.org/Hroudtwolf/purework/wiki/Code%20documentation]
;  */
DeclareModule ExampleModule

  Structure tExampleType
    exampleField.i ; /** Is an example field */
  EndStructure

  Declare.i exampleProcedure
EndDeclareModule

Module ExampleModule

  ; Registers this Module To the PureWork framework.
  PureWork::registerModule("ExampleModule")

  ; /**
  ;  * [DESCRIPTION]
  ;  * 
  ;  * @var integer   exampleVar
  ;  */
  Global.i exampleVar

  ; /**
  ;  * This is just an example procedure.
  ;  */
  Procedure.i exampleProcedure(exampleParam.i)

    Protected exampleVarInScope.i

    If (exampleParam < 0)
      ProcedureReturn
    EndIf

    ; more code...

    ProcedureReturn
  EndProcedure

  ; /**
  ;  * Implements PureWork::onStart() hook.
  ;  */
  Runtime Procedure onStart(*argument.PureWork::tHookArgument)

    ; more code...

    ProcedureReturn
  EndProcedure  

  ; /**
  ;  * Implements PureWork::onExit() hook.
  ;  */
  Runtime Procedure onExit(*argument.PureWork::tHookArgument)

    ; more code...

    ProcedureReturn
  EndProcedure   
EndModule

General rules

  • Camel case notation of identifiers.
  • Expected types. They starts with a lower case t (tMyType).
  • Do not use real tabs. Instead use 2 spaces per tab.
  • Try to imitate the style of the example code.

Updated