« [OT] Mac mini "mini review" | Inicio | Code smells and refactorings »

[XP] Collective code ownership, testing, and coding standards

Extreme Programming (which is both a philosophy and a development methodology) relies upon twelve “development practices”.

From my point of view, one of the fundamental development practices is the “Collective Code Ownership”.

But what does that mean?. Well, as the name says, the project’s code is not owned by any particular developer, so any member of the team can (and in fact must) improve any part of the code at any time.

This approach brings some advantages, no matter if you are pair programming or are just part of a more “conventional” team. First of all, there are no bottlenecks. Also, if you see some code that can be refactored to be improved, you must do it as soon as possible, no matter if you wrote it or not. So, the code becomes much cleaner, but this not only benefits a particular chunk of code or a particular class, but the whole system, which is getting better all the time. Refactorings are also easier, because everybody has some knowledge of the whole project. The overall performance of the team will also increase, because everybody can help any of his co-workers at any time, and it takes also to less frustration (now, you cannot say “my code doesn’t work because THAT idiot didn’t do his job”, just go, and change his code).

But to achieve this goal, there are two things that must be solid as rock. Tests and coding standards.

You are going to work as part of a team that is going to be continuously improving the code. So, there has to be a test for every single class. In fact (but that will be a matter for another post), the tests for a class should be written before writing the class. So, whenever you refactor a class, or a chunk of code, you just have to run the test again. Has everything gone well?. Cool, time to move to another class, then.

But if everybody is going to be able to refactor any chunk of code, there’s a need for a common language. If I’m going to change the code written by another person, everything will be much easier if it looks like my own code: similar variables names, similar method names, the brackets located in the same place, and even the same whitespaces.

The code is the common language that is going to be spoken by the members of the team. So, they are the ones that should define it. But everybody must follow the standard.

By the way, tools like eclipse simplify the work of defining and following a coding Standard. Just define some preferences ( Window->Preferences->Java->Code Style ) and export them to all the team member’s computers.

Comentarios

Hi Cesar,
great article. Nice to here that there are other as developers practicing eXtreme Programming.
I am currently working on general coding standards for as2. I am going to publish the method part sometime this week on my blog.
Cheers
Simon

Cool, Simon. I look forward your post.

By the way, I posted some coding standards I follow some time ago:

http://www.design-nation.net/en/archives/000161.php