1

I have a working web app that I version control using Git - call this v1.0. I learnt a lot during that development including some of the mistakes I made. I now want to re-write parts of the code to follow best (better?!) practices and allow better maintainability. Should I create a new repo or should I clone? (I am using BitBucket).

My intention is to keep the original v1.0 (for now) as the working/'production' version whilst I work on the re-write. What is the best practise to handle this scenario?

SimpleOne
  • 199
  • 1
  • 5

2 Answers2

6

I suppose the answer to your question entirely depends on whether or not you consider the product to be a new one or not. If you consider it to be a new product, you should most certainly clone your repository to start with. Though, I assume if you're rewriting only parts of your program, it is the same product, and therefore you should probably simply create a branch of the original project and work on that.

Once you think you've achieved something which can fully replace the functionality of the old product and you've tested it thoroughly, you can completely replace the contents of the main branch with your development branch.

Neil
  • 22,670
  • 45
  • 76
  • I consider that eventually the rewritten code will replace the old one but may take some time. Perhaps a different question but...: if I am still maintaining v1.0 and may add the odd minor feature, I assume I have to just manually copy any additions from v1.0 across to the new branch? – SimpleOne May 16 '18 at 09:36
  • 1
    @SimpleOne: If you create those v1-feature on branches, then you can merge them both into the v1 mainline and the v2 branch. – Bart van Ingen Schenau May 16 '18 at 12:43
  • @SimpleOne Features you need soon in the main branch can be developed on another branch created from the main and then merged in after you're done, leaving the v2 branch untouched. If the feature can wait, just add it to the v2 branch and it'll get merged along with the rest. – Neil May 16 '18 at 12:56
1

Assuming you use a languanguage language that supports interfaces and dependencyinjection

I would use the same repository and would refactor the old existing code into services with interfaces before the rewrite and then re-implement the services in the rewrite by and by.

benefits

  • both old and new can co-exist in the same repro-branch
  • decide through config if you want to use the old or the new implementation.
  • iterative reimlementation where parts of the old system are reimplemented by and by. The alternative would be a big-bang-replacement of all of the old system with the new one which (from my experience) causes much more problems than a gracefull migration.
k3b
  • 7,488
  • 1
  • 18
  • 31
  • I know, totally not useful comment, but I couldn't resist to not point out the typo "languanguage" and of course not to edit it :) – Wtower Mar 05 '23 at 14:13