程序员必看之★编程原则(中英文对照)★--《Enough Rope to Shoot Yourself in the Foot 》,好久没来,顺便散分,顺便找愿意●兼职●

dongdongshu 2004-02-13 04:39:28
最近忙的要死,好久没来看看JAVA版的XDJM了,今天来看看大家,带上我迟到的新春祝福和摘抄的一些好东东,外带200分~
;)
另外,有北京愿意兼职的朋友,可以发简历至MAIL:dongdongshu@163.com




下面的列表实际上是我的一本书(Enough Rope to Shoot Yourself in the Foot )的目录。这本书是针对C/C++语言来写的,但是这里面的大部分原则也适合一般的编程和使用其它语言的OO编程。如果你想知道这些原则的详细解释,应该参照我的那本书。另外要注意的是,尽管它们是一般编程的原则,但是也总是有例外的。

设计过程
1 编程的本质是:没有意外,最小化耦合,最大化内聚

2 根除复杂性这个恶魔(Part 1)


2.1 不要解决不存在的问题
2.2 解决一个问题,而不要解决一类问题


3 A user interface should not look like a computer program (the transparency principle)

3 用户接口看起来不应该象一个计算机程序(透明原则)
4 Don't confuse ease of learning with ease of use

4 不要混淆易于使用和易于掌握这两个概念
5 Productivity can be measured in the number of keystrokes

5 生产率可以通过击键次数来衡量
6 If you can't say it in English, you can't say it in C/C++

6 如果你不能用自然语言表达,也就不能用C/C++表达
6.1 Do the comments first

6.1 先写注释
7 Read code

7 阅读代码


7.1 There's no room for prima donnas in a contemporary programming shop


8 Decompose complex problems into smaller tasks

8 将复杂的问题分解为多个小任务
9 Use the whole language (Use the appropriate tool for the job)
10 A problem must be thought through before it can be solved

10 解决问题之前应该深思熟虑
11 Computer programming is a service industry

11 计算机编程是服务行业
12 Involve users in the development process

12 开发过程应该有用户参与
13 The customer is always right

13 客户永远是正确的
14 Small is Beautiful. (Big == slow)

14 小即是美(大==慢)


一般开发问题
15 First, do no harm

15 第一,不要有害
16 Edit your code

16 编辑你的代码
17 A program must be written at least twice

17 一个程序应该至少写两次
18 You can't measure productivity by volume

18 不能用代码量衡量生产率
19 You can't program in isolation

19 编程不能与世隔绝
20 Goof off

20 别把编程太当回事
21 Write code with maintenance in mind梩he maintenance programmer is you

21 写代码的时候应该时刻想着维护,假设你自己就是维护者


21.1 Efficiency is often a bugaboo

21.1 追求效率往往导致其它问题


格式化和文档
22 Uncommented code has no value

22 没有注释的代码没有价值
23 Put the code and the documentation in the same place

23 将代码和文档放在一起
24 Comments should be sentences

24 注释应该是完整的句子
25 Run your code through a spelling checker

25 你的代码应该能通过拼写检查
26 A comment shouldn't restate the obvious

26 不要注释显而易见的东西
27 A comment should provide only information needed for maintenance

27 注释中应该只提供对维护有帮助的内容
28 Comments should be in blocks

28 使用块注释
29 Comments should align vertically

29 注释应该垂直对齐
30 Use neat columns as much as possible

30 代码应该尽可能的整齐的分列
31 Don't put comments between the function name and the open brace

31 不要在函数名和第一个花括号之间写注释
32 Mark the ends of long compound statements with something reasonable

32 在较长的代码块之后做标记性注释
33 Put only one statement per line

33 每行只写一条语句
34 Put argument names in function prototypes

34 函数原型中应该写上参数名
35 Use a 損redicate?form to split up long expressions
36 A subroutine should fit on a screen

36 一个子函数的长度应该在一屏以内
37 All code should be printable

37 所有的代码都应该是可打印的
38 Use lines of dashes for visual separation between subroutines

38 使用整行连字符来隔离子函数代码
39 White space is one of the most effective comments

39 空白是最好的注释之一
40 Use four-space indents

40 使用四个空格做缩进
41 Indent statements associated with a flow-control statement

41 缩进所有与一个流程控制语句相关的语句


41.1.Comments should be at the same indent level as the surrounding code

41.1 注释应该与其对应的代码一同缩进


42 Align braces vertically at the outer level

42 在外层垂直对齐花括号
43 Use braces when more than one line is present under a flow-control statement

43 在流程控制语句下面如果有多于一条的语句,应该使用花括号
...全文
1469 123 打赏 收藏 转发到动态 举报
写回复
用AI写文章
123 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphi2java 2004-08-23
  • 打赏
  • 举报
回复
copy:
      ◢██████████◣     
           ◢◣███████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤
loveyuxi 2004-08-23
  • 打赏
  • 举报
回复
up
niuren99 2004-08-23
  • 打赏
  • 举报
回复
ding!!!
hmilyxyz 2004-08-23
  • 打赏
  • 举报
回复
支持!!!!!!!!!!!!!!!!!!!
mikelss 2004-08-23
  • 打赏
  • 举报
回复
up
breeze07 2004-08-23
  • 打赏
  • 举报
回复
up
fatcatman 2004-08-23
  • 打赏
  • 举报
回复
mark
jwbecalm 2004-08-23
  • 打赏
  • 举报
回复
我也来!
delphi2java 2004-08-18
  • 打赏
  • 举报
回复
./ .--...
.-------- 0 .--
/ .......
' ..
'........ ----
. --..
. .---.. -
分 o . ' -.
分 / '
/ ' ' '
\-分--/....... . ' ' ' '
\ __/ - - -' ' ' '
' ' ' '
o ' ' ' '
' ' '
-..'.----------.
I ----------
/////////.
mbh0210 2004-08-18
  • 打赏
  • 举报
回复
up
tangyongtgyg 2004-08-18
  • 打赏
  • 举报
回复
◢██████████◣     
           ◢◣███████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤
sanyou98 2004-08-18
  • 打赏
  • 举报
回复
up
kelvin-w 2004-08-18
  • 打赏
  • 举报
回复
up
tangyongtgyg 2004-08-18
  • 打赏
  • 举报
回复

借一个
      ◢██████████◣     
           ◢◣███████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤
ymm 2004-08-18
  • 打赏
  • 举报
回复
◢██████████◣     
           ◢◣███████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤
wushuren 2004-08-18
  • 打赏
  • 举报
回复
up
agen10120216 2004-08-18
  • 打赏
  • 举报
回复
up
wls981 2004-08-17
  • 打赏
  • 举报
回复

 ██████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤   
          ◢◣███████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤   
          ◢◣███████████◤     
        ◢████◥██████◤         
   ◢█████████   ███◤          
   █████████◤  ◢████████◣     
   ◥███████◤  ◢█████████◤     
    ◥██████   ███◤  ████      
        ███  ◢██ ◢█◣◥███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███ ███ ███      
        ███  ███◢██◤ ███      
        ███  ██████ ◢███      
    ◢██████  ◥█◤██◤ ◥███      
    ◥██████    ◢██ ◢███◤      
      ◥████   ◢███ ◥███◣      
        ◥█◤  ◢███◤  ████◣     
            ◢███◤   ◥████     
           ◢███◤     ◥███     
           ◥█◤        ◥█◤   
pzl686 2004-08-16
  • 打赏
  • 举报
回复

希望兼职
colin2185 2004-08-16
  • 打赏
  • 举报
回复
楼主都出英文版了,牛×
加载更多回复(103)

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧