Coding standards for .Net

  • Thread starter Thread starter mish
  • Start date Start date
mish said:
I would be grateful if people in here would review my article about
.Net coding standards that is soon to be published by Informit.com

It is available at http://mishj.brinkster.net/intranet/netcodingstds.doc

I would welcome any feedback. This has been posted to VB.Net but I
had no response there.

First suggestion - convert it to HTML, and put it up on the web in that
format. Significantly simpler to read!
 
Generally fine, comments in *** against relevant sections

 To conserve resources, be selective in the choice of
data type to ensure the size of a variable is not
excessively large.
*** but - remember integers are faster than shorts or
bytes (and also take up the same space on the stack, but
not in arrays - not certain of this any comments?)

 When writing classes, avoid the use of public variables.
Instead, use procedures to provide a layer of
encapsulation and also to allow an opportunity to validate
value changes.
*** Properties rather than Procedures ? ***


 Require the use Option Explicit in Visual Basic and
VBScript to encourage forethought in the use of variables
and to minimize errors resulting from typographical
errors.
*** and Option Strict ***


 Use Select Case or Switch statements in lieu of
repetitive checking of a common variable using IfThen
statements.
*** normally yes but in short procedures (<32 byte) not
neccesarily, If/Then blocks can be inlined by the Jit but
not select/switch I believe ***

Also ...
It might be worth mentioning the use of underscore for
VB.NET private instance variables eg:-

instance variable _MyStuff
associated property MyStuff

otherwise fine :-)

cheers
guy
 
Thanks Guy for your feedback! I will incorporate it into the final
version that goes to press next week hopefully!
Mish
 
Back
Top