20. 3.コーディングルール策定
コーディングルール策定時に参考となる資料
◆ ESCR
「組込みソフトウェア向けコーディング作法ガイド」
組込みソフトウェア けコーディング作法ガイド」
みソフトウェア向 作法ガイド
◆ ESCR C++言語版
C++言語版
「組込みソフトウェア開発向けコーディング作法ガイド C++言語版」 C++言語版」
◆ MISRA (The Motor Industry Software Reliability Association)
MISRA-C:2004
MISRA-
Guidelines for the use of the C language in critical systems
◆ Sun Microsystems, Inc.
Code Conventions for the Java TM Programming Language
◆ 各プロジェクトのコーディング規約
GNU Coding Standard
Linux Kernel Coding Style
規約・基準の目的を理解した上で活用すること
Developers Summit 2011
21. 3.コーディングルール策定
規約・
規約・規則 目的
ESCR, 組込みソフトウェアを作成する場合に、ソース
ESCR C++ コードの標準化や品質の均一化を進めること
1)新規コーディング規約の作成
2)既存コーディング規約の充実
3)プログラマの研修、独習のための学習教材
出典:翔泳社「組込みソフトウェア開発向けコーディング作法ガイド」
MISRA-C 組み込みシステムで、安全性と移植性と信頼性
MISRA-C++ を確保すること
出典:http://www.misra.org.uk
GNU Coding Standard GNUを綺麗に、一貫性を保ち、導入しやすいシ
ステムにすること
出典:http://www.gnu.org/prep/standards/standards.html
Linux Kernel Coding Linux Kernel の開発者が管理しなくてはならな
Style いことを守らせる
出典:http://lxr.linux.no/linux/Documentation/CodingStyle
Developers Summit 2011
22. 3.コーディングルール策定
(ご参考)Linux Kernel Coding Style の一例
ご参考)Linux
・ Chapter 1: Indentation
… Especially when you've been looking at your screen for 20 straight hours,
you'll find it a lot easier to see how the indentation works if you have large
indentations.
・ Chapter 4: Naming
… Encoding the type of a function into the name (so-called Hungarian
(so-
notation) is brain damaged - the compiler knows the types anyway and can
check those, and it only confuses the programmer.
・ Chapter 6: Functions
… Another measure of the function is the number of local variables. They
shouldn't exceed 5-10, or you're doing something wrong. Re-think the function,
5- Re-
and split it into smaller pieces. A human brain can generally easily keep track
of about 7 different things, anything more and it gets confused.
・ Chapter 8: Commenting
… NEVER try to explain HOW your code works in a comment: it's much better
to write the code so that the _working_ is obvious, and it's a waste of time to
explain badly written code. 出典:http://lxr.linux.no/linux/Documentation/CodingStyle
出典:http://lxr.linux.no/linux/Documentation/CodingStyle
Developers Summit 2011