Page 1 of 1

Good or Bad: one set of library files across dozens of sites

Posted: Fri Oct 09, 2009 3:22 pm
by thinsoldier
A while back I decided to take my mish-mash of common code ("library") and place it in a central location on my server. All my projects live on this 1 server and I've been including these files from that one location every since then.

Every now and then (quite often actually) I have to make a change (minor & major) to some of these files for the benefit of 1 or 2 sites and I'm always afraid of what repercussions these changes will have on the 2 dozen other sites.

Should I just go back to keeping a separate copy of the library files in each project folder?

Re: Good or Bad: one set of library files across dozens of sites

Posted: Fri Oct 09, 2009 4:19 pm
by alex.barylski
If you making changes to your 'library' and it's only required by two of twenty sites, then IMHO it's not library code, but application specific code. You should be able to adjust library code and not have it break other sites.

Can you give concrete examples? Maybe that will help?

Cheers,
Alex

Re: Good or Bad: one set of library files across dozens of sites

Posted: Fri Oct 09, 2009 7:20 pm
by Christopher
I usually call my central code something like 'library01' and then if I upgrade I can create a 'libarary02'. The clients who need the new code get it, but I don't break any sites still using the last version. I can then go through and upgrade sites to the latest code as needed.

Re: Good or Bad: one set of library files across dozens of sites

Posted: Fri Oct 09, 2009 7:53 pm
by josh
Automated tests

Re: Good or Bad: one set of library files across dozens of sites

Posted: Fri Oct 09, 2009 10:16 pm
by thinsoldier
josh wrote:Automated tests
LOL, I wish. I have about 3 years of rewrites or 2 years of transitioning to an opensource framework before I get on your level

Re: Good or Bad: one set of library files across dozens of sites

Posted: Sat Oct 10, 2009 11:57 am
by JNettles
I usually maintain separate instances of my libraries for just this reason - that something might break on another project/component and me not be aware of it for 2+ weeks because I don't know about the problem. Each of these separate libraries, though, is linked to Subversion where I keep the master library, and then I can apply specific library updates to specific applications or even scale an update back to a previous revision if I learn that a certain release has broken some functionality. This lets me apply my specific update quickly to the project I need, and then I can go back later and test the others to make sure nothing is wrong.

So I have a multitude of libraries - but at the same time only 1.

Re: Good or Bad: one set of library files across dozens of sites

Posted: Sat Oct 10, 2009 10:52 pm
by Christopher
I try to not have more that two versions of a library in use at once. I use multiple versions to spread the work out over time, but try to bring everything up to the latest release as soon as possible.

Re: Good or Bad: one set of library files across dozens of sites

Posted: Sun Oct 11, 2009 11:59 am
by josh
thinsoldier wrote:LOL, I wish. I have about 3 years of rewrites or 2 years of transitioning to an opensource framework before I get on your level
If the applications arent under heavy development you can use selenium to test things. It can be as simple as filling out a login form and making sure some specific text is present ( that way if there's a PHP error or something your test will tell you right away ). I even test my .html code nowadays ( so to speak ), using siteuptime.com to assert that some text is present every 2 minutes. Any apache configuration that adversely affects site availability and my "test" will fail and email / SMS me. It may not be much but a little automated testing will go a long way especially with the type of shared code base you're trying to set up.

That, and SVN branching. Make branches of the code and keep accounts on the old branches until you have time to thoroughly test how all new features affect behavior under different configurations, upgrade sites just as needed. With SVN branching & merging its easy to leave an account running an old version and then upgrade them later, if doing this its also helpful to read up "database refactoring" so you can upgrade the database schemas along with the codebase

Re: Good or Bad: one set of library files across dozens of sites

Posted: Mon Oct 12, 2009 5:11 am
by Jenk
You can also write tests for the areas you are going to change, before you change them, to assure they behave the same, after you have changed them.

You don't have to write tests for the entire library if you are only going to be refactoring a small section of it. See Michael C. Feathers' book "Working Effectively With Legacy Code"

Re: Good or Bad: one set of library files across dozens of sites

Posted: Tue Oct 13, 2009 1:11 pm
by thinsoldier
JNettles wrote:I usually maintain separate instances of my libraries for just this reason - that something might break on another project/component and me not be aware of it for 2+ weeks because I don't know about the problem. Each of these separate libraries, though, is linked to Subversion where I keep the master library, and then I can apply specific library updates to specific applications or even scale an update back to a previous revision if I learn that a certain release has broken some functionality. This lets me apply my specific update quickly to the project I need, and then I can go back later and test the others to make sure nothing is wrong.

So I have a multitude of libraries - but at the same time only 1.
I looked into doing this. Unfortunately I'm the only one on me team who's ever used a source code management system and I'm not very good with them anyway. Turns out for some reason on an all OS X network you can't check in/out of a subversion repository when the repo exists on a different machine on the network. :(

Re: Good or Bad: one set of library files across dozens of sites

Posted: Tue Oct 13, 2009 2:51 pm
by JNettles
I don't see why that would be a barrier but then I haven't tried it on any of my OSX networks - we largely keep our development on Windows/Linux and use Macs for media purposes.

Try hitting up an OSX forum for this problem - I can't imagine it would be an actual barrier with SVN being open source and Macs' (supposed) ability to handle files seamlessly.

Re: Good or Bad: one set of library files across dozens of sites

Posted: Tue Oct 13, 2009 3:48 pm
by thinsoldier
It's actually an issue that's been around for a while it seems. It appears to be apple's fault. Apple's employees for their own use have made some sort of work-around but haven't put it into the OS itself.

http://www.vayanis.com/2008/05/04/using ... s-in-os-x/