Checklist for high quality websites part 2

by Mads Kristensen 29. January 2009 05:47

In the first part of the checklist, we looked at creating high quality websites from a client perspective and the tools that helps us do that. In this part we look at the (free) tools that will help us build high quality on the server side of the website.

Code quality

Treat compiler warnings as errors

When you compile your solution in Visual Studio it will by default allow compiler warnings. Compiler warning occurs when there is a problem with the code, but nothing that will result in severe errors. Such a warning could be if you have declared a variable that is never used. These warnings should at all times be treated as errors since they allow you to produce bad code. Keyvan has written a post about how to treat compiler warnings as errors.

StyleCop

The StyleCop Visual Studio add-in analyses your C# code and validates it against a lot of rules. The purpose of the tool is to force you to build maintainable, well documented code using consistent syntax and naming conventions. I’ve found that most of the rules are for maintainability and consistency. After using StyleCop on my latest project I will never build a C# project again without it.
 
Some of the rules might seem strange at first glance, but when you give it a closer look you’ll find that it actually makes a lot of sense.

FxCop

This tool should be familiar to most .NET developers by now. It has existed for a long time and is now on version 1.36. FxCop doesn’t analyze your C# code but the compiled MSIL code, so it can be used with any .NET language. Some of the rules are the same as in StyleCop, but it also actually helps you write more robust methods that result in fewer errors.

If you use StyleCop and do proper unit testing, then you might not need FxCop, but it’s always a good idea to run it on your assemblies. Here's a guide to using FxCop in website projects. Just in case. If you own a Visual Studio Team Edition, then you already have FxCop build in.

Security

Anti-Cross site Scripting (XSS) Library

The Anti-XSS library by Microsoft is not just a fancy way to HTML encode text strings entered by users. It uses white-listing which is much more secure than just trust any input and then HTML encode it in the response. It works with JavaScript, HTML elements and even HTML attributes.

Code Analysis Tool .NET (CAT.NET)

When your website relies on cookies, URL parameters or forms then it’s open for attacks. That’s because all three of them is very easy to forge and manipulate by hackers and robots even. By using the CAT.NET add-in for Visual Studio you can now easily analyze the places in your mark-up and code-behind that is vulnerable to those kinds of attacks. CAT.NET analyzes your code and tells you exactly what the problem is. It’s easy to use, understand and it lets you build more secure websites.

* Only $4.95/month ASP.NET & Windows 2008 + IIS 7 Hosting! FREE SQL Included

Tags: , ,

Security | Server-side

Comments

1/29/2009 6:38:50 AM #

Brian Kim

Thanks for great post.
This series is really helpful. Will there be part 3?

Brian Kim United States |

1/29/2009 7:09:42 AM #

Jesper Lind

Have anybody used the AntiXss 3? Please help if somebody knows the trick.

Jesper Lind Sweden |

1/29/2009 8:10:38 AM #

Marwan

thanks,
NDepend also is a great tool for analysing assemblies, it gives a lot of useful graphs and charts.

Marwan Tunisia |

1/29/2009 1:36:04 PM #

Mark Kordon

I would really love to see StyleCop for VB :p

Great post, though!

Mark Kordon Denmark |

1/29/2009 3:17:22 PM #

Mads Kristensen

@Marwan,

NDepend is unfortunately not free. You can download a trial but it has less features and expires after a few months. The checklist only features free tools.

Mads Kristensen Denmark |

1/29/2009 4:20:28 PM #

trackback

Checklist for high quality websites part 2

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com |

1/29/2009 7:39:04 PM #

trackback

Checklist for high quality websites part 2

Thank you for submitting this cool story - Trackback from DotNetShoutout

DotNetShoutout |

1/30/2009 8:48:16 AM #

Josh Delong

I've been using StyleCop for almost a year now when I started a new project and it has been awesome for code sharing. I've tried to stress the importance and benefits that StyleCop offers but they just don't seem to listen.

Another tool I like to use is Resharper but I like the add-on for Cyclometric complexity. Everybody thinks I'm weird when I've got a method that's over a specific limit and I'm trying to figure out how to refactor it more.

Anyway great post Mads and keep up the good advice.

Josh Delong United States |

1/30/2009 10:26:52 PM #

Kabon

Hi.. i have a same problems with jasper AntiXss 3. Nice to know you Mads. Just following you on twitter

Kabon United States |

2/1/2009 10:57:07 PM #

Amer Gerzic

Very useful ... thanks!

Amer Gerzic United States |

2/2/2009 11:49:13 PM #

Dityo Nurasto

Thanks for the post. StyleCop would help me a lot.

Dityo Nurasto Indonesia |

2/6/2009 7:47:50 PM #

Nebbercracker

I wish there was StyleCop for VB also Frown

Nebbercracker United States |

4/7/2009 10:15:42 AM #

shengwei Mao

easy to use
thank u

shengwei Mao People's Republic of China |

Comments are closed

About the slave

Mads Kristensen Mads Kristensen
Web developer at ZYB and founder of BlogEngine.NET. More...

LinkedIn ZYB Facebook Last.fm Twitter View Mads Kristensen's profile on Technorati

The Lounge

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008