Showing posts with label Starting a website. Show all posts
Showing posts with label Starting a website. Show all posts

Monday, 21 May 2012

Running StyleCop for all projects in Visual Web Developer 2010 Express


In my previous post, I hinted at a method of getting StyleCop to run under the free versions of Visual Studio, particularly Visual Studio 2010 Express and Visual Web Developer. Getting this tool to run is remarkably simple, although there are some differences between running under this environment and running under the paid for Visual Studio editions.

Although these differences mean that StyleCop does not seem as embedded in Visual Studio as previous environments that I have worked with, I have become used to working in a certain way, and it no longer bothers me that my work environment is a little different to my home working environment.

What is StyleCop

For those who are not already using this fantastic tool, StyleCop is a Visual Studio plugin which enforces certain rules against how code is formatted, code location, and where and when documentation headers are used. Of course, if you have never used StyleCop before, this doesn't seem like that much of a big deal, and can even seem like a waste of time. I fully admit that, when I first came to using the tool a few years ago, I was a little sceptical at first. Implementing the rules became a little bit of a hassle, especially as I always left the enhancements until last thing, resulting in potentially hundreds of "errors". It wasn't until I moved to a new company that had never used the tool that I realised how much easier code that has followed the rules is to pick up and find your way around. It is true to say that StyleCop will probably not enhance any of your actual code, but if it means that you need to think about what a method does in order to decorate it with a documentation header, then that can't be a bad thing, can it?!

Installing StyleCop

Back to the main purpose of this post, how to go about installing StyleCop on a Visual Studio Express environment. First things first, you will need to download and install the MSI, which can be found on the CodePlex website. Once the installation has finished, you will need to find the .Targets file. This should be located in the MSBuild folder C:\Program Files (x86)\MSBuild\StyleCop\v4.7\StyleCop.Targets. Move this file to the following folder (you may need to create this folder if it doesn't already exist!) C:\Program Files\MSBuild\4.0\Microsoft.CSharp.targets\ImportAfter\.

That's it, it really is that simple. You will need to restart Visual Studio, but from now on, every time you build a project, StyleCop will run.

Happy Coding :0)

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)

Sunday, 6 May 2012

Coding on a Sunday night

It's a quarter past twelve on a Sunday evening and I'm sitting here blogging and coding. I really should be in bed right now, my alarm is due to go off in a little over 5 hours. But the fact is that I am enjoying myself. The database for the new website has had a few minor changes this evening. Most of this is not because of any redesign as such, but because of me forgetting to include a few key parts of the website. I should have done a proper project plan before starting, but hey, I'm a developer, not a project manager. I know this is completely the wrong attitude if we look at all the books on building websites. There are certain rules that everybody is supposed to follow. But the fact is that many of the websites that we use on a day to day basis do not follow this. They are the sorts of projects that are developed in code as fast as they are developed in the head of the person that is coding them.

So where are we at? I have the database there, with a few parts still missing (the scripts are coded, but the columns and tables themselves are not there yet. I will be putting them in later, and they are definitely in mind when I'm working on the front end!). I also have a few pages, and parts of pages for the new site.

The security has been taken care of, although at this time I am not entirely sure whether I am going to rebuild the security side of things myself. At the moment, I am reluctant to do so, as the project already has the standard MVC security there and I have no users on the site. It may be changed in the future, but not now. The pages I do have are slowly taking shape. I am concentrating on the front end user interface at the moment. The CSS is taking shape and I am testing against Google Chrome and Internet Explorer just to make sure that it all works. Of all of the Internet browsers, Internet Explorer is the one that I have had the most trouble with during my career. IE has always had trouble keeping up with certain Internet standards which have been adopted early by the likes of Google Chrome and Firefox, so much of the front end testing will be against IE. Looking at the stats from my other blog, I will be needing to make sure that I have tested against several versions of IE. For this, I am using IETester, a great program that allows you to test the front end of a site in multiple versions.

I am also thinking about the front end from a mobile browser perspective. Any site these days needs to have mobile support as many of the potential page hits will be from a mobile source. This needs a little more investigation as it is not something I have really had to deal with before.

Back to the coding!

As a side-note, I am leaving the Foo Fighters alone for tonight, and using one of the other motivational tools that I have to hand... I don't know quite what it is about The Social Network that gets me motivated, but it never fails to get me in the mood to create something!

Thursday, 3 May 2012

In the beginning...


I have been a website developer for more than ten years now, working for various companies on corporate, subscription based websites. The sorts of sites that I have worked on are those sites that are never supposed to be commercial to the outside world, the sorts of websites that are used within companies, but those companies customers are never aware that they exist, or are never really thought about. Some of the companies I have worked for were using Internet technologies to do the sorts of things that only a few years before would have been taken care of by windows based systems. The technologies that we we were using and creating put us at the forefront of technology.

It was all very interesting, it really was, and I still enjoy doing it, and I'm sure that if I stay doing it, I will still enjoy the challenges that come with these sorts of online applications for years to come. But I have decided to have a little fun for myself.

I have wanted to build my own website for a long time now, but have never really got around to it. I have had plenty of ideas for different ideas, but somehow life always got in the way and the idea would eventually dwindle to nothing or be replaced by a better idea. I wish I could say that it was all about time and nothing to do with motivation, but I can't. I simply can't. The motivation to get a project off the ground and put the hard work in has always been a bit of a problem. But as I get older, the desire to start my own website has become much more prominent. I'm hoping that this desire can be the driving force behind this project.

The idea is a relatively simple one. The site needs to be fun. It needs to be attractive to it's target audience. Ideally, I would like the site to make a little money as well. It doesn't have to be a lot of money. To be honest, at this stage I am really hoping for nothing more than the site to pay for its own hosting and domain registration. The project is supposed to be a little fun, not something that I am going to struggle to have enough time to do outside of the day job.

I will reveal more about what the site actually is as I go through the development, but at the moment, I can't reveal too much. All I can say is that some of the ideas are there, and some ideas are still being formed.

So, without further ado, let's get to it!