Monday, August 07, 2006

Code Naming Conventions

There is a pretty good (albeit brief) series on Code Naming Conventions by The Igloo Coder:
http://igloocoder.com/archive/2006/07/04/394.aspx

The series first looks at the need for conventions and essentially makes the argument that consistency is paramount to good team coding. I agree.

He then covers Local Variable, Module Variables, Functions, Methods, Parameters, Properties, Classes, Interfaces, Super (and Base) Classes, UI Controls, and SQL Server Objects (also applicable to Oracle, MySQL, etc.)

I happen to agree with his observations as well as his conclusions. These are the same standards I use when something else is not mandated.

The following is a brief summary. Do read the series; there is more detail. It's an easy read.


Local VariablesstrHungarian (Yes, seriously, Hungarian Notation) strEmployeeName
Module Variables_strHungarian _intRecordCount
FunctionsPascalCase (Verb-Noun) DeterminePrice()
MethodsPascalCase (Verb-Noun) PoundSalt()
ParameterscamelCase DoThing(bool isGoodBoy) * He actually makes note to avoid bool and use enum instead
PropertiesPascalCase read his blurb for more details
ClassesPascalCase
InterfacesIPascalCase ICanPontificate
Super(Base) ClassesRead his blurb
UI ControlsstrHungarian txtUserName * Alternate is to prefix HTML controls with 'h' => htxtUserName
SQL Server ObjectsPascalCase (Noun-Verb) EmployeeAdd * The Noun-Verb is specific to Stored Procedures

No comments: