views:

111

answers:

2

On my current project, I'm stuck in an ASP.Net 2.0 Webforms anti-pattern quagmire. I am aware of the myriad of anti-patterns we're using (huge code-behinds, no separation of concerns, untestable code, and on and on). Now, I'm not interested in rescuing this application from this situation as it's too far gone. Instead, my focus is on other projects that I will undertake in the near future for which I would very much like to graduate from these anti-patterns.

I have done a LOT of study recently in ASP.Net MVC, good OO design (Head First OOA&D and Eric Evans DDD book), design patterns (Head First Design Patterns), and automated unit testing with mocks (through presentations and blogs). I'm looking for advice on how to tackle an ASP.Net MVC 2 project while achieving good design, flexibility, maintainability and testability. What would you recommend that I do to achieve this? Here's my thoughts so far:

Utilize an iterative approach to development outlined in Head First OOA&D, and apply design patterns where applicable. Use Linq to NHibernate for data access, but perhaps avoid the Repository pattern (Ayende on his blog indicates that it's an unnecessary layer with NHibernate). Should I employ StructureMap or other IoC container? What else do I need to know in order to build a rockin ASP.Net MVC 2 application with membership, support for a media gallery, and some simple custom CMS for administrative users?

It seems to me that there should be a balance between anti-patterns, and potentially getting bogged down with DDD. Just a thought.

Thanks, Andy

+2  A: 
  • IoC container: useful for any application
  • Repository or not?: depends on what your application will do.

Trying to fit every app in the same design with the same tools is an anti pattern as well, so ask more specific questions.

The single responsibility principle is the most important design principle. Your code will be testable when you use that everywhere, but it's the hardest thing to learn when you are not used to it.

Paco
I see your point, but it seems to me though that there are tons of opportunities to steal designs/patterns/approaches when dealing with websites that persist things to a database since this is so common. There are a million different approaches though, and that's what I'm trying to get a handle on. I'll be more specific in the future. Thanks!
Andy
Yes, there are a lot of patterns, but you don't need them all. I am currently reading POSA4, about messaging patterns. The book contains about 150 different patterns about messaging. I need only need 10-20 of them in an application, but different ones every in different apps. PoEA by Fowler describes most relational database specific patterns, that are also used in NHibernate. I don't use a relation database in every web-app, and sometimes multiple kinds of databases.
Paco
A: 

SharpArchitecture

I think you will found great ideas in this base architecture: SharpArchitecture

Sharp archictecture was developed using the previous version of ASP MVC but the basis and patterns still apply : )

Hope it helps you.

BONUS: somebody said NHibernate out-of-the-box? : D

SDReyes
Is the validation stuff in SharpArchitecture now obsolete with the new model validation with the DataAnnotations namespace in MVC 2?
Andy
Hi Andy! in brief, not really. each one of the validation frameworks you choose has pros and cons, and you should consider which one is better for your application. these are excellent comparisons -to start-:http://goneale.com/2009/06/25/aspnet-mvc-validation-refresh-best-techniques-frameworks/http://temebele.wordpress.com/2009/12/03/net-validation-framework-analysis-draft/Hope it answers your question : )
SDReyes