Branching and versioning strategy for shared libraries

development-processreleaseversion controlversioning

These posts seem related, but my brain is starting to melt, trying to think this through 😛

My employer has just started using source control, primarily because before they hired more developers, the "repository" was the hard drive of the lone dev, who works mainly from home. All of the .NET code he'd written was checked in en masse, and there is a lot of duplicated (read: copy-pasted) functionality. Right now, our SCM system is glorified backup.

I'd like to pull some of the duplicated code into shared libraries. I'm leaving the original repo alone so that we don't break anything—we can move and/or refactor existing code as and when needed. So I've set up a repo just for new code, including libraries.

My problem revolves around versioning the libraries without miring us in excessive process: having acknowledged that we need a more coherent approach, with more devs all writing very similar code, management and the other devs are open to reorganising things, but it probably won't go down well if the solution starts to affect productivity.

The ideal solution in my obsessive mind is to build the libraries separately, with each dependent project built against deliberately chosen, compatible versions of them. That way, we know exactly which clients have which versions of which libraries, can more reliably reproduce bugs, maintain independent release branches for products and libraries, and not break each other's projects when changing shared code.

This makes updating the libraries cumbersome though, particularly for the dev who works from home. I expect the libraries to change quickly, at least initially as we (finally) pull the common bits together. It's quite possible that I'm completely overthinking this and we'd be fine just building everything against the most recent library commits, but I'd like to at least be prepared for the day we decide that some components have to be independently versioned and distributed. The fact that some of the libraries will have to be installed in the GAC makes versioning particularly important.

So my question is: what am I missing? I feel like I've fixated on one solution and am now trying to find variations on it that will make changes smoother. What kinds of strategies have you used to solve this kind of problem before? I realise this question is all over the place; I'll do my best to clean up and clarify any points of uncertainty.

And as much as I'd love to use Mercurial, we've already spent money on a centralised commercial SCM (Vault) and switching isn't an option. Besides, I think the issue here goes deeper than choice of version control tool.

Best Answer

I commend your initiative. This should yield a number of benefits for the organization as you implement this. I would move the code rather than copy it. Having copies will likely result in incompatible changes which will need to be resolved.

There will be some pain as the libraries are developed and stabilized. Once that is done, the benefits will arrive. Remember that the interfaces to the library are essentially a contract with the projects working with the contract. You may have the advantage of removing old interfaces as you may be able to determine if they are used.

While the libraries are stabilizing, getting new libraries should probably be part of the code update process. You may want to schedule commits of library changes. Announcing the code being moved may help reduce conflicting changes.

The libraries should be treated as separate projects and stabilized as soon as possible. Once they are stabilized (particularly the interfaces) it should be easier to integrate changes with other projects. New libraries should work with old code. Tag stable library releases with their own release id. Try to treat the libraries as you would third party libraries.

Related Topic