Monday, May 28, 2012

Slides and summary from my presentation on Data Access - Best Practice

Earlier this month I gave a presentation at the Capgemini Microsoft User Group with the title 'Data Access - Best Practice'. In the presentation I went through why the data access blocks in an application are so important, common issues related to data access that you find in many code bases and how to solve these, and at the end a summary that wraps it all up into the following best practice principles:

  • Have small, simple classes that do only one thing.
  • Use the Criteria Pattern to decide what data to retrieve.
  • Use joins to retrieve as much data as needed in one query.
  • Avoid lazy loading.
  • Use parameters instead of concatenated strings.
  • Always check for permissions when retrieving, creating, updating or deleting data.
  • Use transactions to rollback when errors occur.
  • Use the Gateway Pattern to reduce ORM dependency.
  • Have a strict Frontend layer, Business layer, Data Access layer.
  • Verify quality through Integration Tests.

Here are the slides from the presentations: