Saturday, December 6, 2008

T-SQL Interactive Coding Standards

T-SQL Interactive Coding Standards Why?
  • Maintainable Code
  • Easy to read, easy to understand
A few standards to whet your appetite
  • CAPITALISE keywords
  • Indent your code
  • Comments, comments & more comments
  • Do not cal functions repeatedly
  • No anonymous inserts
  • Don’t use select *
  • Avoid using not equals operators
  • Don’t use hard-coded values
  • Catch errors
Ideas time…
  • Put URLs of pages you’ve followed in code
  • Use transactions where appropriate
  • Name your transactions – helps with debugging
  • Segment your code into sections
  • Don’t put JOINs into the WHERE clause
  • Columns in neat orders
  • Don’t use one line statements
  • Debug tables
  • Cursors are a necessary evil? (Don’t know if I agree with this)
  • Table variables vs. Temp tables (work out which one is appropriate)
  • Indexing
  • Pseudo code in comments
Resources

No comments:

Post a Comment