MariaDB Coding Standards

XKCD Standards

Coding standards are often as hotly debated as vim vs emacs and other developer arguments. Viewers of the show Silicon Valley will all know the “tabs vs spaces” scene and how passionate people can be about it. Whilst I do personally have a preference (I’m not sharing it here), I feel it is much more important that people stick to one standard for a code base.

Standards Story

Several months ago a new community developer for MariaDB Server sent me a message asking where to find our coding standards document. After a bit of searching I realised we did not have one, and if we want to onboard new developers we definitely should have one. This is actually made a little more difficult for MariaDB Server because it has taken in many external projects, mostly as storage engines, and these all have their own coding standards.

So, I set out to create a coding standards document that is within the MariaDB code base. The general idea is that it is descriptive of the intention for the main MariaDB code base for people to follow. With it being in the code base itself it is possible for people to amend it via a pull request, just as they would any code changes.

For now the document only covers the main MariaDB Server source code, but every engine could conceivably have a similar document. The end goal being that once the definitions are nailed down these documents become prescriptive rather than descriptive. We could even create a CI test to make sure that commits adhere to the standards.

Where can I find them?

You can find the coding standards as a Markdown document in MariaDB Server 11.0 onwards called “CODING_STANDARDS.md”. Also, when you open a pull request against MariaDB Server 11.0 or higher, it will ask you to confirm that you have followed the standards. We will be going through the MariaDB knowledgebase and updating the developer guides to point to this. The guides inside the MariaDB Server source code have already been modified accordingly.

Featured image: XKCD Standards, used under a Creative Commons Attribution-NonCommercial 2.5 License.

Published by Andrew Hutchings

Chief Contributions Officer for the MariaDB Foundation