Table of Contents
Abstract
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. Martin Fowler in: Refactoring, improving the design of existing code
Having multiple developers working on the same source code creates a need for a basic set of coding rules to adhere to. A proper code layout makes it a lot easier for others to read, understand, enhance, debug, and clean-up code.
Having a coding style is quite common. Two of the more prominent examples are The Linux kernel coding style /usr/src/linux/Documentation/CodingStyle and the GNU coding standard http://www.gnu.org/prep/standards/.
This document describes how to layout code written in YCP: how to name your variables and functions, how to place braces, and how to indent blocks.
Most programmers have a personal style of writing code. The rules presented here might not match your personal preferences, but will help everyone work on the code as a team. Helping out and fixing bugs is easier with a common coding style.
The following set of rules tries to be complete, but probably isn't. Feel free to write the maintainer, lukas.ocilka@suse.cz, about mistakes and omissions.
These rules should apply to C, C++, and YCP code alike, even though the examples use YCP. As much as possible, additionally apply them to Perl code.