Posts Tagged ‘Style’

perfect commentary style

星期四, 6月 12th, 2008

e.g:

/* Project Babel
 *
 * Author: Livid Liu <v2ex.livid@mac.com>
 * File: /htdocs/core/V2EXCore.php
 * Usage: V2EX Page Core Class
 * Format: 1 tab indent(4 spaces), LF, UTF-8, no-BOM
 * 
 * Subversion Keywords:
 *
 * $Id: V2EXCore.php 316 2008-01-15 00:25:31Z v2ex.livid $
 * $Date: 2008-01-15 08:25:31 +0800 (星期二, 15 一月 2008) $
 * $Revision: 316 $
 * $Author: v2ex.livid $
 * $URL: http://project-babel.googlecode.com/svn/trunk/htdocs/core/V2EXCore.php $
 *
 * Copyright (C) 2006 Livid Liu <v2ex.livid@mac.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

编码风格大战..

星期六, 4月 14th, 2007

逛V2EX发现一四个月前的老帖.

1. 一行要不要限制在 80 个字符以内
2. 到底是用 Tab 缩进还是空格缩进好
3. 缩进宽度到底是 4 好还是 8 好,或者其它值。
4. 大括号要不要单独占一行
5. 大括号要不要缩进
6. 不是必要的大括号是不是一定要加

我的回答是:

1. 一行要限制在 80 个字符以内
2. 用 Tab 缩进好
3. 缩进宽度是 8 好。
4. 大括号要单独占一行
5. 大括号要缩进
6. 不是必要的大括号是一定要加的