reedcwilson/catan — pull request #21 by reedcwilson (2014-04-08 04:20:41+00:00)
Title: Server/persistence

# Attention! -- readme

## ImplementingTemplate Method Pattern

As I was implementing the DataContext I noticed that there was going to be a lot of code duplication all over the place. Also, Jake brought to my attention that there is no way to get the connection. I fixed that by passing the DataContext into the constructor. You will use it to create prepared statements.

### Changes
- modified all access classes. They no longer have get, update, delete, insert. They now simply provide **prepared statements** to the base class (which is new), **validate parameters** and **initialize objects**. In the long run I think this results in less code even though there are more methods. The methods will be smaller and you shouldn't need to write any helper methods.
- I removed those lame intermediate abstract classes and am doing all caching on the new base class -- DatabaseAccess
- I created an exception **DataAccessException**. Throw this exception whenever there is something invalid (from the checkParameters method)
- Command, User and Game now implement an interface called **PersistenceModel** which allows me to set the Id of the object after inserting it into the database
- Since I got rid of those intermediate classes I have to use the Interface IAccess to reference the various Access classes. The server will need to cast these to their types when getting them back. -- I am still a little stuck on this one.

Please let me know if you have any questions. I think that this will be easier overall. I am sorry if you have already spent a lot of time on this already.