views:

45

answers:

2

I have inherited a really awful webforms application that is all kinds of bad--an untestable hairy mess of datasets and Page_Load events. Object oriented? N-tier? Unit tests? source control? All academic niceties to the team that built this mess.

It started life as an asp classic app, got mostly ported to VB.NET. Management denied my request to "nuke the entire site from orbit" and start over.

[Insert discourse on how ASP.NET MVC is absolutely, positively the only sane way to to .net websites anymore]

I know we might be able to interoperate between the legacy webforms and mvc. The question is, can we leave the legacy code in VB and build the new stuff in C#? I want to force the conversion to C# so the team doesn't fall back into bad habits.

Is there an MVC 2 Areas strategy that we could use here?

A: 

I'm intrigued by your implication that the team's bad habits are caused by use of VB. There are plenty of bad habits in any language: the trick is not to switch language, but to learn good habits.

Anyone's post about this kind of thing is going to be opinion - and in my opinion you'd be better off teaching them to program properly in VB than making them learn a new language that they may struggle with. I've seen great, stable, maintainable VB code and I've seen horrendous, messy C# code. Try not associate a programming language with the quality of output of a team that happens to be using it.

(For the record, I develop in both VB and C# and would always choose C# given the choice - but not because I think I write better code in C#.)

Dan Puzey
+2  A: 

I'm not surprised the idea of a total rewrite was shot down. In general that is a recipe for delay and more bugs, regardless of how buggy the current project.

As far as I know it depends on the kind of project. If the existing project is a web application then no you can not. You could reference external libraries built in C# due to the CLR, however, you will not be able to bake C# code right into the project. This is done all the time and is mostly acceptable.

If the existing project is a web site project then I would have to say yes you can. However, you should not willingly do this unless there is an absolute need to do so. This is just asking for a difficult to maintain project and essentially requires you to do a lot of management in the web.config. I would strongly advise against doing this.

site reference: http://timheuer.com/blog/archive/2007/02/28/14002.aspx

I think you should be able to put this method together with those from the Google search mentioned by an earlier poster. Its going to take a bit of work though.

Additionally, coding practices are pretty much entirely unrelated to the language and from my experience working with mostly web forms and a little MVC, both have their time and place. I would look at laying down a set of practices that must be followed and enforce them using code reviews. Any new code you write would be kept clean and tight while you can also update old code to use standards.

Mike Cellini