Saturday, 19 May 2012

Patterns and Practices

In a previous post, I mentioned that I had written the bulk of the database that will drive the website. This is still true, but after reading a few articles on the Code First pattern, I have decided to leave the database portion of the website alone for the time being and concentrate far more on the API using the code first and repository patterns. This is something new for me, as in previous projects, I have always had a database to read everything from before doing anything by way of front end testing. The pattern is made really simple when using Ninject to create a mock data store from which to read the data, and I have to say that I am really enjoying coding this way.

Generally, when using the code first pattern, a developer will allow the Entity Framework to go ahead and create the database for them when they run the project. I'm not sure I quite agree with doing it that way. I might allow it to create the database when I need to, and see what it comes up with and how it fits in with my knowledge of database schema design. To be honest, the bulk of it should be OK, but I like to be more in control of my own indexes and foreign key constraints as part of the database design which is why I am a little reluctant to have the database generated. Time will tell as to whether this works out.

In the meantime, I now have a fully working setup of Visual Studio Express which works a lot more like the professional setup that I use in my day job. It takes a bit of hacking around, but getting things such as StyleCop to run under the environment is very important to me. I admit that using StyleCop to evaluate code structure is something that a lot of developers don't like, but it is something that I find extremely useful as it helps the navigation of the code, and makes me a little less lazy with the documentation of the project. Getting StyleCop to run under Visual Studio Express for all projects can be a little fiddly, but a little research led me to a really simple solution which I will share in my next post.

In the meantime, it's back to the coding for a little more of my Sunday afternoon, after which I need to go and find a replacement for my broken kettle (one of the most important tools in any developers armoury!)

Happy Sunday :0)

No comments:

Post a Comment