10诫,修订 [英] 10 Commandments, Revised

查看:70
本文介绍了10诫,修订的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,请原谅我,如果之前已经出现过,但我没有找到任何内容

Google网上论坛。


我跑过去了C程序员的10条诫命的旧打印副本a / b
,但它让我思考:哎呀,这些已经开始显示他们年龄的b $ b。我想知道clc的人会通过修改的方式提出什么建议?


所以,如果你要为C程序员制作修订的10条诫命,那么
$ b你会加上$ b吗?你会删除什么?你会改变什么?


Grant D. Watson
gr ********** @ yahoo.pleasedontspamme.com (使用这个!)

解决方案

Grant D. Watson写道:

好的,请原谅我,如果之前已经出现过,但我在谷歌团体中找不到任何东西。

我跑了很久以前,C版程序员的10条诫命的旧印刷版本已经让我思考:哎呀,这些都开始显示出他们的年龄。我想知道c.l.c上的人会通过修改的方式提出什么建议?

所以,如果你要为C程序员制作修订的10条诫命,你会添加什么?你会删除什么?你会改变什么?

Grant D. Watson
gr ** ********@yahoo.pleasedontspamme.com (使用这个!)




1.永远不要假设

2.参见1.


" Grant D. Watson"写道:


好的,请原谅我,如果之前已经出现过,但我在谷歌团体中找不到任何东西。

我不久之后,他们在C程序员的10条诫命的旧版印刷品上跑了过来,它让我想到:哎呀,这些都开始显示出他们的年龄。我想知道c.l.c上的人会通过修改的方式提出什么建议?

所以,如果你要为C程序员制作修订的10条诫命,你会添加什么?你会删除什么?你会改变什么?




你知道Annotated Edition?

http://www.lysator.liu.se/c/ten-commandments.html


-
Er ******** *@sun.com


In< 20 ********************** *****@mb-m14.aol.com> vb*******@aol.com (Grant D. Watson)写道:
< blockquote class =post_quotes>我在C程序员的一个旧版印刷版上跑了一段时间,它让我思考:哎呀,这些已经开始显示
他们的年龄。我想知道c.l.c上的人会通过修改的方式提出什么建议?

所以,如果你要为C程序员制作修订的10条诫命,你会添加什么?你会删除什么?你会改变什么?




让我们看看它们:


1你经常运行lint并研究它关于

关注的声明,因为它的感知和判断确实超过了你。


gcc -Wall -O和具有类似诊断功能的编译器删除

需要皮棉。所以,这条诫命的有效性取决于你的
编译器。


2你不应该遵循NULL指针,因为混乱和疯狂等待
最后
.


s / NULL / null

3如果他们将所有函数参数强制转换为预期类型

已经不属于那种类型了,即使你确信这不需要这个b $ b,以免你在b
时对你进行残酷的复仇至少期望它。


仅适用于可变函数。


4如果你的头文件未能声明你的库的返回类型

功能,你要用最细致的方式宣告他们自己,以免你的计划受到严重伤害。


已过时。


5你应该检查所有字符串的数组边界(事实上,所有

数组),肯定是你有一天在某人的某个地方输入``foo''''

类型``supercalifrag ilisticexpialidocious''''。


比以往任何时候都更有效。


6如果函数被广告以在发生错误时返回错误代码

困难,你要检查那个代码,是的,即使

检查你的代码大小增加三倍并且在打字时产生疼痛

手指,因为如果你说你不能发生在我身上,那么众神将会因你的傲慢而惩罚你。


有效。


7你要学习你的图书馆,努力不再重新发明它们,无条件地将你的代码简短,可读,你的日子
愉快而富有成效。


有效。


8你要使你的程序的目的和结构清晰。

男人使用One True Brace Style,即使你喜欢它也不会因为你的创造力更好地用于解决问题而不是

创造了美丽的新阻碍理解。


不能同意更多!


9你的外部标识符在前六个字符中应该是唯一的,虽然这种严厉的纪律令人厌烦,而且它的必要年代在你看似没有结束之前伸展,但是你要撕掉你的头发

out and mad mad在那个命运的日子里,当你想要在一个旧系统上运行你的
程序时。


这些天有点生疏。具有此限制的系统通常不具有标准C实现的
。但是,除了通用的

图书馆需要自己的名字空间之外,规则相对容易

跟随。


10你要穿衣服,放弃,并放弃邪恶的异端邪说,这就是所有的世界都是VAX,并且没有商业合作。

坚持这种野蛮信仰的愚昧的异教徒,即使你当前的机器时间很短,你的计划可能会很长。


s / VAX / Windows PC


所以,大部分都幸免于难。应该增加一个强调便携式编程重要性的新项目。还有另一个因为混淆C和C ++并且不鼓励用C ++编译器编写的C代码编写的b $ b。但是我对国王完全没有能力

詹姆斯的英语,所以我不打算写他们;-)


Dan


Dan

-

Dan Pop

DESY Zeuthen,RZ集团

电子邮件: Da*****@ifh.de


Okay, forgive me if this has come up before, but I didn''t find anything in
Google Groups.

I ran accross an old printed copy of the 10 Commandments for C Programmers a
little while back, and it got me thinking: "Gee, these are beginning to show
their age. I wonder what the folks on c.l.c would suggest by way of revision?"

So, if you were to produce a Revised 10 Commandments for C Programmers, what
would you add? What would you remove? What would you change?

Grant D. Watson
gr**********@yahoo.pleasedontspamme.com (Use this one!)

解决方案

Grant D. Watson wrote:

Okay, forgive me if this has come up before, but I didn''t find anything in
Google Groups.

I ran accross an old printed copy of the 10 Commandments for C Programmers a
little while back, and it got me thinking: "Gee, these are beginning to show
their age. I wonder what the folks on c.l.c would suggest by way of revision?"

So, if you were to produce a Revised 10 Commandments for C Programmers, what
would you add? What would you remove? What would you change?

Grant D. Watson
gr**********@yahoo.pleasedontspamme.com (Use this one!)



1. Never assume anything
2. See 1.


"Grant D. Watson" wrote:


Okay, forgive me if this has come up before, but I didn''t find anything in
Google Groups.

I ran accross an old printed copy of the 10 Commandments for C Programmers a
little while back, and it got me thinking: "Gee, these are beginning to show
their age. I wonder what the folks on c.l.c would suggest by way of revision?"

So, if you were to produce a Revised 10 Commandments for C Programmers, what
would you add? What would you remove? What would you change?



Are you aware of the "Annotated Edition?"

http://www.lysator.liu.se/c/ten-commandments.html

--
Er*********@sun.com


In <20***************************@mb-m14.aol.com> vb*******@aol.com (Grant D. Watson) writes:

I ran accross an old printed copy of the 10 Commandments for C Programmers a
little while back, and it got me thinking: "Gee, these are beginning to show
their age. I wonder what the folks on c.l.c would suggest by way of revision?"

So, if you were to produce a Revised 10 Commandments for C Programmers, what
would you add? What would you remove? What would you change?



Let''s look at them:

1 Thou shalt run lint frequently and study its pronouncements with
care, for verily its perception and judgement oft exceed thine.

gcc -Wall -O and compilers with similar diagnosing capabilities remove
the need for lint. So, the validity of this commandment depends on your
compiler.

2 Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end.

s/NULL/null

3 Thou shalt cast all function arguments to the expected type if they
are not of that type already, even when thou art convinced that this
is unnecessary, lest they take cruel vengeance upon thee when thou
least expect it.

Valid for variadic functions only.

4 If thy header files fail to declare the return types of thy library
functions, thou shalt declare them thyself with the most meticulous
care, lest grievous harm befall thy program.

Obsolete.

5 Thou shalt check the array bounds of all strings (indeed, all
arrays), for surely where thou typest ``foo'''' someone someday shall
type ``supercalifragilisticexpialidocious''''.

More valid than ever.

6 If a function be advertised to return an error code in the event of
difficulties, thou shalt check for that code, yea, even though the
checks triple the size of thy code and produce aches in thy typing
fingers, for if thou thinkest ``it cannot happen to me'''', the gods
shall surely punish thee for thy arrogance.

Valid.

7 Thou shalt study thy libraries and strive not to reinvent them
without cause, that thy code may be short and readable and thy days
pleasant and productive.

Valid.

8 Thou shalt make thy program''s purpose and structure clear to thy
fellow man by using the One True Brace Style, even if thou likest it
not, for thy creativity is better used in solving problems than in
creating beautiful new impediments to understanding.

Couldn''t agree more!

9 Thy external identifiers shall be unique in the first six characters,
though this harsh discipline be irksome and the years of its necessity
stretch before thee seemingly without end, lest thou tear thy hair
out and go mad on that fateful day when thou desirest to make thy
program run on an old system.

A bit rusty these days. The systems with this limitation usually don''t
have standard C implementations. However, except for general purpose
libraries that need their own name space, the rule is relatively easy to
follow.

10 Thou shalt foreswear, renounce, and abjure the vile heresy which
claimeth that ``All the world''s a VAX'''', and have no commerce with
the benighted heathens who cling to this barbarous belief, that the
days of thy program may be long even though the days of thy current
machine be short.

s/VAX/Windows PC

So, most of it survived with little changes. A new item emphasising the
importance of portable programming should probably be added. And another
against confusing C and C++ and discouraging the writing of C code that
compiles with C++ compilers. But I''m completely incompetent on King
James'' English, so I''m not going to write them ;-)

Dan

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de


这篇关于10诫,修订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆