Coding Style

Now is probably a good time to collect together our thoughts on HOW we should write code

This should be as full a list as possible, without being over the top !

I think the best would be to put down some lists as soon as we think of them, then re-order and tidy up later on.

I am sure we all have some thoughts and ideas, so lets get them down and see where we end up.

  • Avoid Global Variables wherever possible. If globals are unavoidable then prefix them with a g so that everyone else knows
  • Each function or sub should fit on one screen. If it is larger than this then it probably needs to be split into smaller functions
  • Keep code OUT of dialogs as much as possible
  • Use sensible names in public function and sub declarations so that the parameters are obvious to someone else
  • If you are passing an integer as a mode variable, consider using an enum
  • Every public method should have a docblock
FileName

Trimble.TPS.Mobile.MyClass.dll Trimble.TPS.Desktop.MyClass.dll

Namespace

Trimble.TPS.MyClass Trimble.TPS.MyClass

Public Methods
  • All should be prefixed tps
  • CamelCase after tps eg tpsDoSomeWork
Public Properties
  • NO PUBLIC VARIABLES - use specific Get/Set
  • prefix tps_ eg tps_MyProperty
  • internal property just has the tps removed eg _MyProperty
Events
  • Events prefix e eg eThisEvent
Application Level Globals
  • always prefix g eg gSomeVariable
Enums
  • ALL public methods should have enums for passing switch parameters
Control Names
  • use prefix lbl,txt,cmb,grd, use SOMETHING
Documentation
  • EVERY public method / property has a proper DocBlock
  • Minimum in the docblock are calling parameters and return types
  • Internal methods should have simple docs where appropriate
Guidance
  • If it doesn't fit on one screen then it is to big - Break into functions
Testing
  • Each component should have a self contained test application - Even if it doesn't do anything except prove the component runs
DOTNET
  • Desktop - 2.0
  • Mobile - 2.0
 
devnews/coding_style.txt · Last modified: 2010/02/17 02:25 by wynsleeman
Recent changes RSS feed Creative Commons License Driven by DokuWiki