Next Blog.

Next Blog.
1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17

Link Web.
skywebboard   sms.web   Goobonk

วันศุกร์ที่ 30 กรกฎาคม พ.ศ. 2553

Oh sock coding codingstyle #1 on Google:)


codingstyle.com to day hot and hit.
Coding Style
'Coding style' refers to the way source code is formatted. For C, this involves things like brace placement, indentation, and the way parentheses are used. GNOME has a mix of coding styles, and we do not enforce any one of them. The most important thing is for the code to be consistent within a program or library - code with sloppy formatting is not acceptable, since it is hard to read.

When writing a new program or library, please follow a consistent style of brace placement and indentation. If you do not have any personal preference for a style, we recommend the Linux kernel coding style, or the GNU coding style.

Read the (Standards)Writing C info node in the GNU documentation. Then, get the Linux kernel sources and read the file linux/Documentation/CodingStyle, and ignore Linus's jokes. These two documents will give you a good idea of what we recommend for GNOME code.

Indentation Style
For core GNOME code we prefer the Linux kernel indentation style. Use 8-space tabs for indentation.

Using 8-space tabs for indentation provides a number of benefits. It makes the code easier to read, since the indentation is clearly marked. It also helps you keep your code honest by forcing you to split functions into more modular and well-defined chunks - if your indentation goes too far to the right, then it means your function is designed badly and you should split it to make it more modular or re-think it.

8-space tabs for indentation also helps you to design functions that fit nicely in a single screen, which means that people can understand the code without having to scroll back and forth in order to understand it.

Example my coding style.
=====================================:)
//If you use Emacs, then you can select the Linux kernel indentation style by including this in your .emacs file:://

(add-hook 'c-mode-common-hook
(lambda ()
(c-set-style "k&r")
(setq c-basic-offset 8)))


//On newer Emacsen or with a newer cc-mode, you may be able to simply do this instead://

(add-hook 'c-mode-common-hook
(lambda ()
(c-set-style "linux")))


//If you use vim, then you can select the GNOME kernel indentation style by including this fragment in your ~/.vimrc file://

set ts=8
if !exists("autocommands_loaded")
let autocommands_loaded = 1
augroup C
autocmd BufRead *.c set cindent
augroup END
endif

=====================================:)

What is your style., coding program.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น