views:

151

answers:

2

I understand the pros of using namespaces within the actual application layers but when it comes to the front tier, I am not so sure.

My project is a Website (not WebApplication) and I get all sorts of problems (missing references, for one) when I try and include "namespaced" user controls. Despite explicit declarations in web.config under system.web - pages - controls - add.

When it comes to the actual views, the webforms: when you create a new page, Visual Studio creates the codebehind classname from the path where you chose to create the file. So most times, I'd say that class names will be unique. If you move around pages, then it will become strange to see say Start_DefaultPage but under another sub folder.

To summarize: Is it recommended to put namespaces into the web tier? What are the pros and cons?

+1  A: 

Yes. In the future, you may decide to include external libraries that (coincidentally) use the same class names, and you do not want to have a namespace collision, as you very well know can occur. In addition, you may have web applications in a virtual directory that will inherit the properties outlined in the parent web.config. You do not want to mess with namespace conflicts there, either. Generally speaking, it is just a good programming practice.

Wayne Hartman
Good to know I wasn't too far off with my assumptions. Trying ASP.NET is fun, but it's very "different" compared to other technologies (and vice versa :)).I'll continue using namespaces for my aspx and ascx.files!
Adam Asham
+1  A: 

Your problem is that you are using a web site "project". Stop doing that, and you'll stop having these problems.

Web Sites are a mistake that Microsoft made. There's no need for you to make their mistake into your mistake.

John Saunders