Monday, July 20, 2009

Some things I’ve been learning lately

I’m using ASP.NET MVC in my current project at work and have been learning a lot in the process. I’ve read a lot of articles and watched some videos. I recently went through the NerdDinner Tutorial which was quite helpful and read most of Professional ASP.NET MVC 1.0. But there’s a lot more to writing a production app than can be learned from reading or even working through a tutorial – so it’s been a slow process, but I feel like I’m learning a lot.

The past few years I’ve been working mostly in classic ASP. I’ve done some C# on the side and a couple basic ASP.NET projects. There are a few reasons I chose to do this project on a new platform. I want to stop developing new features in an outdated platform. I want to make use of some functionality built-in to the .NET Framework. And I want to learn and use some better development practices.

Actually developing a real project in ASP.NET MVC has been a bit of a leap though. I feel like I’m biting off a big chunk. Here are some of the things I’ve been learning:

  • I’m trying to be test-driven (well, except for database access, file access and HTML output – but at least they’re isolated so the other parts are easier to test). It seems to be going better than my previous attempts.
  • I’ve been learning Rhino Mocks for mocking and stubbing.
  • I’m using an object-relational mapper (Fluent NHibernate) for the first time to hopefully reduce redundant database-access code. There’s still a fair amount of raw SQL, but the surrounding code is simpler. (I didn’t use LINQ to SQL because Visual Web Developer Express doesn’t support connecting to an external SQL server.)
  • I just added StructureMap for dependency injection (DI) so that my classes can be more loosely coupled. I started out with poor man’s DI, but just switched to rich man’s… er, using a container.
  • I’m trying to minimize the use of “magic strings” by making use of the strongly-typed HTML helpers in the MVC futures library. I also found the TestControllerBuilder from MVC Contrib helpful for testing HttpContext.
  • I feel like I’m learning OO better. Living in VBScript for so long didn’t help much. I’m also learning the MVC pattern and framework, ASP.NET, C# 3 and LINQ better. I’m currently working on a custom role provider to take advantage of roles from the existing app.
  • On that note, I’ve been realizing how much infrastructure is in the existing app that I took for granted that I will have to port, convert to a web service or use COM interop for.
  • I can sort of deploy it to IIS6 but it’s not one step. Still trying to figure out the best solution.

I was a little scared about all the different things I might have to learn for this project, and looking at this list I can see why. I didn’t absolutely have to learn all of this, but I like to do things “right” and I want to grow as a developer. I believe I’m past the hardest new challenges. I’ve got basic usable functionality. There’s still work to do, but hopefully that will progress more quickly.

There are still several things I would like to learn and do in the future, including:

  • Finish this project
  • Test-driven JavaScript
  • Acceptance/integration testing
  • Continuous integration
  • Scripting database setup and changes
  • Switch from Subversion to Git at work
  • Do all new development in a more modern platform than classic ASP and eventually convert most or all of the older code

That’s it for now. If you found any of it interesting then cool beans ;-). Feel free to comment if you’d like.