views:

201

answers:

4

I have the need to build lots of sites that are very similar, but not exactly the same, using ASP.NET 2.0.

I'm trying to find the best way to make generating these sites quick and easy.

The sites will be used to collect information about a user, and there will be multiple steps for each site.

The sites will all collect similar information, but some sites may require less or more information than others. Additionally, certain form fields will need to be populated from different database tables, based on the site.

I would like to use a Microsoft patterns & practices solution, but I'm not sure that there is one that fits this scenario.

My current thinking is that I will put as much business logic as possible into an external assembly and then write a custom Web user control for each step for each site. I will include these user controls in a master page's Panel control.

I don't like this solution because each site will be nearly duplicating the code for the other sites.

How can I improve upon this design?

The main obstacle is that the sites are similar, but sufficiently different.

Thanks!

Alex

+1  A: 

you can create base classes which handle all of the common functionality and then have your site specific controls inherit from their respective base classes and then implement their specific implementations.

YonahW
+1  A: 

We face this problem all the time. What we do is to have a common library that all our sites use, and to bury shared functionality in classes or utility modules in this library. Each site can then use those objects or utility functions as is, or extend the common classes. Keep in mind that these shared classes can include all kinds of things, including code-behind for pages and user controls that you can inherit from and extend.

Deciding what goes in the app and what goes in the common library is one of the hardest things about our business, though. Put it in the common library and you lose flexibility; put it in the app and you risk having duplicate code to maintain.

If you have a fairly complex database setup, it might be worth your time to come up with a framework for specifying your db schema in XML and having your app enforce that schema and build any additional SQL infrastructure that you need based on that definition (e.g. utility views, stored procedures, etc). We did this and it resulted in a huge productivity boost.

Herb Caudill
Thanks for your input. Do you have any examples of the user control inheritance? I see how I could inherit and override the code behind, but I don't see how I could change the presentation (programmatically adding Web controls muddles presentation and logic).
AlexWalker
A: 

Have you looked into Monorail (www.castleproject.org) this is an implementation of themvc pattern, similar to Ruby on rails with a few nice view engines, I prefer Nvelocity. from castle project as well you can use n implementation of ActiveRecord that makes life real nice. if you are on that trail also have a look at coln ramsay screencasts .

To be honest all ms solutions are real fat another great thing about the castleproject is that is totally open source so you can learn loads from their code

Miau
While Monorail looks great, I'm afraid that the business requires that we stick with ASP.NET Web Forms for this project.
AlexWalker
A: 

How about using an Application Framework like DotNetNuke or mojoportal? They both provide flexibility and enable you to develop websites very quickly with common functionality. Leaving you to develop custom modules where the functionality you require may be different. There are also thousands of other modules that can be bought which provide excellent functionality.

However we chose to use WCSF and enhanced upon it.
All the above mentioned projects are open source and some good examples of code to learn from.

I know it may be a late answer but I hope it helps

Gary Woodfine