Skip to content

Who's the owner? Shared code vs. code ownership

June 23, 2009 by Mendelt Siebenga

I think it's widely recognized that shared code is important in agile teams. It's an effective way to streamline your development process, making your teams more flexible and productive. Transitioning from code-ownership to shared code can be hard. Lets compare the two, look at the problems in transitioning from one to the other and see how we can ease this transition.

Shared code is only a corollary practice in extreme programming but most agile teams I've seen implement it successfully. Many other teams are still in a situation where team members have what I call code ownership, the code base is divided into parts that can only be edited by certain persons or groups within the team. Usually the code is divided along lines of expertise, for example database-professionals develop the database, the back-end and domain logic is developed by one or more experts, and interaction designers and UI developers are responsible for the user interface. The reasons for this division are usually efficiency, people work on the parts of the code that fit their skill set, and responsibility, when something is wrong it's easy to find the guilty party by looking at what piece of the code failed.

Why Share?
In practice things work a bit different.
Code ownership is actually not very efficient, most non-trivial features will take changes in most of the layers in the application. This will create unnecessary dependencies between team members and unnecessary delays.
Having people take responsibility for pieces of code isn't very useful either. Eventually implemented features are what count. I have seen many situations where no-one took responsibility for a defect in a feature because of code ownership. The database-guy blamed the back-end guy, the back-end guy blamed the UI team etc.
Code ownership is also risky. Specialization like that will create knowledge silo's in your team. If the database guy gets hit by a bus who will take his place?

So what's keeping you?
So if shared code is the way to go, how do we get there? Is just telling everyone to edit any piece of code enough? Of course it's not that easy. When you remove safeguards you'll have to replace them with other safeguards, there are a couple of things that need to be in place to enable shared code, responsibility and trust

Responsibilty
We already looked at responsibility, making individuals responsible for parts of the code is not the solution. In teams with shared code the whole team is responsible for the whole code base. But if more than one person is responsible then effectively no-one has responsibility.
But in parts of the code base aren't that important to our clients. Working features are, user-stories are. Most agile methodologies let people take responsibility for implementing features or user-stories at the start of an iteration. Dividing responsibilities along the same lines as the actual deliverables results in less finger-pointing and more cooperation.

Trust
In many cases developers themselves are opposed to the idea that any other team member can change the code they worked on at any time. Team-members need to trust each other in order for shared code to work, they need to be sure that every time a team member edits some piece of code the code will be better than before the edit. This means the team actually needs to agree on what 'better' is. So there need to be coding standards. It's also good to have a code-review process in place. Of course instant code-review in the form of pair-programming would be even better. A good version control system is a good safety net in case things do go wrong. Practices to get quick feedback on code quality like TDD and continuous integration also help.

Shared code is an important agile practice but getting there takes some effort. Getting rid of code ownership without a support structure can cause problems agile practices in order to guarantee consistent quality and to work in a responsible way. Agile practices like TDD, continuous integration and pair programming help keep quality high and responsibiltiy needs to shift from code to features in order to be successful.

About the Author: Mendelt Siebenga has been working as a software developer for close to ten years. For the last five years he has been applying practices and ideas from XP, Scrum and Lean in several adverse conditions like in fixed-price projects, teams distributed over several timezones and even during a SOX compliance implementation.

Comments

Need to scope your comment...

June 23, 2009 by Mike Cottmeyer (not verified), 37 weeks 5 days ago
Comment id: 2761

While I agree with your thesis in general... for most small teams... there are some organizations where shared code ownership does not work. What about when the software application is a system of systems and one system is legacy COBOL and the other is .NET. There needs to be some context around these statements or they get disregarded as naive in larger organizations.

Mike

One size does not fit all

June 24, 2009 by Cary Harper (not verified), 37 weeks 5 days ago
Comment id: 2763

Features implemented may be what counts for the business unit, but implementing a feature using industry standards and optimizing for maintainability should be the goal of the development team.

I think its important to mention that while code sharing has many benefits, its still important to have expert groups that can go deeper and more quickly through technology spikes and lead the designs for the rest of the team. Those specialist can have more expertise in certain areas of software development technology and as such can be very useful as long as the information they garner is disseminated to the rest of the team and you have code sharing.

I.e. we have DBA's to gain more specialized optimization than would otherwise be possible.

If defects are logged against the stories as those stories are tested, and you know who worked on each story then ownership of defects should be clear. The team in general should have a culture of excellence in that we don't play and are not interested in who's fault it is, rather we just want to resolve the issue in the best way possible and improve the project as a whole.

RE Need to scope your comment...

June 24, 2009 by Mendelt, 37 weeks 5 days ago
Comment id: 2764

@Mike
I do hope that it was clear I was talking about sharing code within teams, not between teams. Your system of systems example touches on that point, there will probably be many teams working on a system of systems that each have their own component to work on. Coordinating that work is not the problem I was talking about. But even in a system of systems situation each team can share code between it's members.

I don't think large organizations are much different than smaller organizations in this respect. Other than the fact that large organizations often have regulations in place that make sharing code more difficult (I've been in organizations where programmers were not allowed to touch databases even in the test environments.) But these are artificial constraints. Large organizations often find it easier to trust rules than their employees to do the right thing.

The whole point of the article was code sharing will improve your teams when you take the right precautions. Your .Net/COBOL team is exactly the right environment for something like this. Giving the .Net and COBOL devs access to each other's code with the right safeguards in place will improve communication and cooperation. But if you do it without the right precautions you can indeed get into trouble

RE One size does not fit all

June 24, 2009 by Mendelt, 37 weeks 5 days ago
Comment id: 2765

@Cary Harper
You're completely right. you still need different roles in your teams. DBA's, testers, UI experts etc. But having those people touch each other's code sometimes will not hurt them too much.

Having cross functional teams (not the subject of this article but an interesting subject nonetheless) does not mean you don't have specialists. Even when you start out with generalists different people will be drawn to different work, eventually some people will specialize. The point of sharing code is to not constrain your people to their specialization.

For example, I'm not a database expert. But when I need to implement a feature that needs an extra field in a table somewhere I can probably do it myself and it would annoy our DBA if I had to bother him for every little change like this. With the right guidelines, code review (or pair programming) and some automated testing in place we can be sure I won't make a mess of the database. But when we need to optimize indexes or replicate the database I'm glad we have a DBA on the team.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <i> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <br> <blockquote>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.

Best of AgileSoftwareDevelopment.com