Technologies To Improve Group-Written Code?
iamdjsamba asks: "I've been working at my company as a programmer for about 4 months now, and it's apparent that the working methods could do with a refresh. Practices that we need to start changing are things like: non source-controlled changes that get uploaded to our website when they aren't ready; poor code commenting; and very little in the way of code reuse (if I write a class that could be useful to others, I have no easy way of telling everyone about it). I'm currently looking into ways to change this, and was wondering if anyone on Slashdot had experience of what's good and what's not?"
Sometimes I've found management to be an obstacle in enforcing some of these types of rules. If that happens, a few ideas for coping:
...
....
> 1. Limit access to deployment server - only one or two person can access the server.
Sometimes managers insist on either retaining their own access to production boxes or delgating that authority to the 'village idiot'. See below.
> Even better - create automatic deployment scripts that can be run on the server by those persons.
If the wrong people are given access to the production boxes, try to limit everyone's access to running a limited set of scripts that log all operations performed, along with who did them, and let you easily roll back the last change. Don't let anyone access the box directly. Then put together an automated failure report that tracks what changes occurred before the box broke. This information can be useful in the uphill battles to stop the idiots from breaking the server.
If the question "why did the server go down?" comes up every month, it's useful to have a printout ready that says that each time it happened was immediately after Jimmy moved untested code into production, along with details.
> @. Create staging server - where you deploy the code from repository. Do not deploy to
> production until you get a "go" from the client on staged version.
Also, if the validation process becomes subverted by pushes to "get it out the door", set things up so it can be easily rolled back.
> 3. Use Trac -
Never used it, but it sounds like the kind of thing you definitely want.
> 4. Use framework - frameworks usually come with a set of coding concepts that ease code reuse.
Maybe; some are good, some are bad. I've had the misfortune of helping developers select the right framework, only to have management scrap the recommendations and buy overpriced crap that's "oooh, shiny!". If you adopt frameworks, treat them as "on probation". Review and be prepared to get rid of them if they aren't supporting you.
> 5. Communicate findings about bad practices - just talk with your colleagues and tell
> them how can they write better code, with examples
Don't preach. Write it down (Wikis are good for that), and reinforce it in a non-threatening environment like peer code reviews/stand-up meetings.
> 6. Introduce unit testing -
Agreed.
Sounds like your organization is either relatively new to the software engineering game or just plain incompetent. The fact that you at least recognize the problem is a good thing. First, find out if there are others like you that find the current practices inefficient. If there are some others, band together and come up with an attack plan focusing on small progressive steps. You can't change the big machine overnight, so you will have to be patient.
"Practices that we need to start changing are things like: non source-controlled changes that get uploaded to our website when they aren't ready;
Build a better practice then show it to people. Hopefully you do have some sort of CM tool for your source code and you have a couple of cowboys just uploading source code. IF you don't, check out Subversion (http://subversion.tigris.org/). To deal with the cowboys, gather some stats on the problems causes by cowboy code being uploaded and then present the hard evidence (this unapproved code cost us $5000 dollars in man-hours) to a manager. The kicker is you MUST have a plan ready to present that will cure the problem. For instance, make the server only accessable by a software librarian/integrator and only he/she can put stuff up on the server which requires code be at least built and run against the current development tip.
poor code commenting;
I am a proponent of well written code. If code is too complicated or hard to understand such that is needs commenting, I say re-write it. Of course there are exceptions. A good ol' fashion code review process could fix this. And I am not talking about a heavy weight CMMI process here.. Simply print out the damn code and hand it to a seasoned developer who owns a red pen.
and very little in the way of code reuse (if I write a class that could be useful to others, I have no easy way of telling everyone about it).
This happens a lot, especially with teams that haven't melded together and don't communicate well. Simple weekly stand-up meetings can help (short, 10 minute meetings in a room with no chairs) just to communicate issues and announce cool things like your nifty new class. It also helps to have a group website or message board so you can say "I did xyz, and I think everyone might benefit. See my blog/post on the group site". Don't have a site or anyone with IT skills to get one up? Try Joomla, it is an easy site content management system that is great for this sort of thing (http://www.joomla.org/)
Good luck! If you play your cards right you could be the hero, or the zero, so watch out!