Quick--where's your coding convention document? What do you mean you don't know?
If you're like most developers, the coding convention document you were given when you started your job is in the bottom of a drawer somewhere or gathering dust on that top shelf, out of reach. Coding conventions are supposed to be useful tools for creating high quality code, but because they are rarely written by the developers themselves, coding conventions are often viewed as handcuffs shackling developer style and creativity.
This doesn't even take into account developers who work on multiple projects. Or do consulting work. If you do, you can find yourself having to learn different coding conventions several times a year.
The Complex Adaptive System
In Managing Agile Projects, Sanjiv Augustine says:
Living systems such as projects are complex in that they consist of a great many autonomous agents interacting with each other in many ways. The interaction of individual agents is governed by simple, localized rules and characterized by constant feedback. Collective behavior is characterized by an overlaying order, self-organization, and a collective intelligence so unified that the group cannot be described as merely the sum of its parts. Complex order, known as emergent order arises from the system itself, rather than an external dominating force. These self organizing Complex Adaptive Systems (CAS) are adaptive in that they react differently under different circumstances and co-evolve with their environment.
Development teams are a perfect example of a Complex Adaptive System. They're made up of technical, creative, highly intelligent, and autonomous developers interacting with each other in many ways.
Coding Conventions In the Complex Adaptive System
No wonder developers react badly to coding conventions, especially when they are imposed from higher up the food chain or are leftovers from a previous project. This kind of coding convention:
- Doesn't arise from the system itself.
- Is an external dominating force.
- Doesn't react differently in different circumstances.
- Doesn't evolve with the environment.
For it to be useful to a development team that matches the Complex Adaptive System criteria, a coding convention will have to consist of rules that are:
- Reactive to feedback.
With these rules, emergent order comes from the team itself, rather then an external dominating force like a coding convention. These CASs are adaptive in that they react differently to different situations and environments, and evolve over the life of the project.
The Agile Coding Convention
Simple rules let your team deliver high-quality code as efficiently as possible. With this in mind, my agile coding convention consists of these simple rules:
- Make your code look like other people's code.
- Use the simplest design possible.
- Don't re-invent the wheel.
- Document your code.
- Keep security in mind.
- Work in increments.
- Work in iterations.
- Have your code reviewed.
- Don't stay blocked.
- Do unto others as you would have them do unto you.