views:

577

answers:

4

What is the best method for utilizing a single code base for multiple websites?

We have validation and session management libraries that we use on multiple websites. Is there a best practice for keeping a single copy rather than having to maintain updates of local copies for each website?

+1  A: 

If you're using source control (and if you're not, you should be), you can branch the common code. Group it into folders and branch the folders into each website. Changes can be merged back to the origin and then propagated to each website.

Dan Goldstein
I think how to keep up with the propogation and avoid breaking changes is part of the question.
Joel Coehoorn
+2  A: 

Make everything configurable through site specific configuration files. Changing code per client is a way to drive yourself crazy. Make the code multi-tenant from the start and through configuration, like skinning css, you can easily deploy more.

Todd Hoff
+2  A: 

If you are using subversion, you can branch your common code and use svn:external to keep an up to date version (or a specific tag) of the common code in your repository. (http://svnbook.red-bean.com/en/1.0/ch07s03.html)

Other SCM systems may have similar features.

jon hohle
A: 

We have a single codebase that we share with all websites we build. We're an ASP.NET shop, so in practice that means a VB.NET class library. This includes extensions of the basic ASP.NET controls (a custom SqlDatasource, a custom FormView, a custom CheckboxList, etc.) as well as other custom web controls and a library of utility classes and functions.

Typically a website consists of a 2-project VisualStudio solution, one project for the website itself, and another project for the shared codebase. When we build the solution, any changes to the common codebase are built at the same time. Changes to the codebase are checked in to source control and propagated to other websites whenever they're opened back up and the latest code is pulled down.

Herb Caudill