views:

53

answers:

3

I have a program that I have chosen to duplicate because it is being modified to meet the requirements of a completely different market. However, many aspects of the program, especially much of the content, will remain unchanged (for now). The particular market we are targeting is subject to regulation by the government, and having dealt with such situations before, I have learned that anything can change at any time.

I basically have two options to choose from:

Option 1: Don't duplicate the program. Make changes to the existing program based on user types. Option 2: Duplicate the program. Make necessary changes to templates and programming.

If I choose option 1, the code is going to become unmanageable very quickly with caveats littered throughout the code. It will also be difficult to make very large changes to the program.

If I choose option 2, and need to make a change to an area that is common between both programs, I'll have to do it twice.

I feel like both choices are a bad idea, and I feel like there must be a much better way to handle this issue. Is there anything else I can do?

How do you manage multiple programs that all do similar things?

StackOverflow seems to do this very well with their multiple StackExchange sites.

The project is a web application using PHP, HTML, CSS, JS, PostgreSQL, Apache and SVN.

Thanks in advance!

+2  A: 

I would recommend reading first chapter of the refactoring book, by Martin Fowler. It deals with a very similar dilemma.

Kozyarchuk
+3  A: 

How about:

  • Maintain a coherent codebase of the common parts
  • In every place where the two “versions” of the software need to do something different, call a function
  • Declare that function in a “version”-specific source file
  • Have two such source files that you can swap in and out

This is particularly easy in PHP where you can really just declare a global function in a file somewhere.

Timwi
A: 

Thank you for the submitted answers.

My team and I have decided to manage this issue using branches and tags in Subversion.

We will maintain a trunk of code that will serve as the base program. When we need to heavily modify the trunk for a new market, we will create a branch from the trunk and make the necessary changes there.

This will allow us the keep very good records of all the changes we make and where they have been applied.

Bryan Downing