阅读优秀的代码 [英] Reading great code

查看:53
本文介绍了阅读优秀的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!


在他最近的新闻通讯中,嵌入式专家Jack Ganssle说,编程学生以及专业开发人员应该读取

优秀代码 (高质量/精心设计的代码有效)。他甚至给了b $ b给出的例子。一个是uC / OS-II操作系统,另一个是用于所述系统的
TCP / IP堆栈。

你知道优雅和高品质的其他好例子吗?代码

公开可用,以便开发人员可以查看并学习?


看到它会很有趣,甚至可能会讨论为什么它是所以

太棒了。

解决方案

你好!


>

在他最近的新闻通讯中,嵌入式专家Jack Ganssle说

编程学生,以及专业开发人员应该阅读

优秀代码 (高质量/精心设计的代码有效)。他甚至给了b $ b给出的例子。一个是uC / OS-II操作系统,另一个是用于所述系统的
TCP / IP堆栈。


你知道其他优秀的优雅例子吗?和高质量的代码

公开可用,以便开发人员可以查看并学习?


看到它并且可能是偶数会很有趣讨论为什么会如此

太棒了。



大多数程序员从未达到他们能够写作的水平

great码。你怎么定义伟大的有争议的是因为涉及很多艺术执照的b $ b。这不是一门硬科学。但是,那些

的人可以坚持不懈地理解如何将程序转换成美丽的代码,类似于国际象棋大师的方式

本质上理解如何在棋盘上移动他的棋子。它是各种心理分块的组合。经过多年的实践后获得的技能(即,能够快速,轻松地查看

问题,而无需详细说明构成部分的内容。

问题)。通过这种方式,您可以创建一个优雅的解决方案,而无需花费太多时间来考虑它。然而,很难将这个教给别人。你可以

展示了很多合理的原则,但这需要大量的练习和一定的天生能力来掌握它。不幸的是,基于我自己的b
体验,大多数人都无能为力,就像大多数人永远不会成为优秀的棋手一样,无论他们多么努力(即使是加里卡斯帕罗夫) as

你的老师)。不过,我自己的建议很简单。将您的所有代码设为

尽可能通用且可重用(且可靠)。几乎任何

计划的95%或更多可以通过这种方式制作,但95%的程序员都不理解

这个基本规则。这是一个伟大的程序员的标志,但是(如果

你可以掌握它,你将会在写伟大代码的路上 - 如果你

想要离线这个我可以给你发一些记录良好的C ++样本给

演示)。


gt8887b写道:
< blockquote class =post_quotes>
你好!


在他最近的通讯中,嵌入式专家Jack Ganssle说

编程学生,以及专业人士开发人员应该阅读

优秀代码 (高质量/精心设计的代码有效)。他甚至给了b $ b给出的例子。一个是uC / OS-II操作系统,另一个是用于所述系统的
TCP / IP堆栈。


你知道其他优秀的优雅例子吗?和高质量的代码

公开可用,以便开发人员可以查看并学习?


看到它并且可能是偶数会很有趣讨论为什么会如此

很棒。



这是旧的(1976年),而且是帕斯卡,但是。 。 。


我的钱,有史以来最好的编程技巧书是算法+数据

结构=程序,由Wirth(ISBN 0-13- 022418-9)。优雅的算法,

巧妙地实现了,并且他在某种程度上说明了创建的过程

(有时包括混乱和错误的开始)而不仅仅是呈现

完成的程序似乎来自空气稀薄。


FWIW,我使用过uC / OS-II并同意它也是优秀的代码 - 它有

相同的直接到达的质量。作者(Labrosse)

在附带的书中详细解释了他的代码以及许多有用的操作系统概念。


问候,

-rick-


John Browning< no_spam@_nospam.comwrote:


< snip>


我自己的建议很简单。将您的所有代码设为

尽可能通用且可重用(且可靠)。几乎任何

计划的95%或更多可以通过这种方式制作,但95%的程序员都不理解

这个基本规则。



我非常赞同。可重复使用不那么 - 因为根据我的经验,

你制作它的可重用性和通用性越高,为了完成你所拥有的一项任务就越复杂。在眼前。我经常发现

然后我再也没有重复使用有问题的组件,因为它使得它可以重复使用所有的问题。这些天,我用一种不太可靠的方式构建东西,直到我看到我已经有了*可以重复使用的代码

稍微调整一下。那时在

的地方进行适当的单元测试,在保持

原始使用工作的同时进行更改通常并不太难。


如果你确定你确实需要代码从

开始是通用的,那当然是另一回事。

这通常被称为YAGNI:你不会需要它


http://c2.com/xp/YouArentGonnaNeedIt.html

http:// zh .wikipedia.org / wiki / You_Ain''t_Gonna_Need_It


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复该群组,请不要邮寄给我o


Hello!

In his recent newsletter embedded expert Jack Ganssle says that
programming students, as well as professional developers should readh
"great code" (hight quality/well-crafted code that works). He even
gives to examples. One is uC/OS-II operating system and the other is
TCP/IP stack for said system.
Do you know of other good examples of elegant and high-quality code
that is publicly available so that developers may look at it and learn?

It would be interesting to see it and may be even discuss why it is so
great.

解决方案

Hello!

>
In his recent newsletter embedded expert Jack Ganssle says that
programming students, as well as professional developers should readh
"great code" (hight quality/well-crafted code that works). He even
gives to examples. One is uC/OS-II operating system and the other is
TCP/IP stack for said system.
Do you know of other good examples of elegant and high-quality code
that is publicly available so that developers may look at it and learn?

It would be interesting to see it and may be even discuss why it is so
great.

Most programmers never reach the level where they''re capable of writing
"great" code. How you even define "great" is debatable as there''s a lot
of artistic license involved. It''s not a hard science. However, those who
can consistently do it intrinsically understand how to convert program
requirements into beautiful code similar to the way a grandmaster at chess
intrinsically understands how to move his pieces around the board. It''s a
combination of various mental "chunking" skills achieved after years of
practice (i.e., the ability to quickly and effortlessly see through a
problem without having to dwell on the constituent parts comprising that
problem). From this you can create an elegant solution without having to
think about it too much. It''s hard to teach this to others however. You can
demonstrate a lot of sound principles but it takes tremendous practice and a
certain innate ability to master it yourself. Unfortunately, based on my own
experience, most people are incapable of it just like most can never become
a great chess player no matter how hard they try (even with Gary Kasparov as
your teacher). My own advice would be simple however. Make all your code as
generic and reusable (and robust) as possible. 95% or more of almost any
program can be made this way but 95% of all programmers don''t understand
this fundamental rule. It''s the hallmark of a great programmer however (if
you can master it you''ll be on your way to writing "great" code - if you
want to take this offline I can send you some well documented C++ samples to
demonstrate).


gt8887b wrote:

Hello!

In his recent newsletter embedded expert Jack Ganssle says that
programming students, as well as professional developers should readh
"great code" (hight quality/well-crafted code that works). He even
gives to examples. One is uC/OS-II operating system and the other is
TCP/IP stack for said system.
Do you know of other good examples of elegant and high-quality code
that is publicly available so that developers may look at it and learn?

It would be interesting to see it and may be even discuss why it is so
great.

It''s old (1976) and it''s Pascal, but . . .

For my money, the best programming technique book ever is "Algorithms + Data
Structures = Programs", by Wirth (ISBN 0-13-022418-9). Elegant algorithms,
artfully implemented, and he illustrates somewhat the process of creation
(including sometimes the messiness and false starts) rather than just presenting
finished programs which seem to come from thin air.

FWIW, I have used uC/OS-II and agree that it is excellent code as well - it has
that same quality of being "straight to the point". The author (Labrosse)
explains his code well in the accompanying book along with many useful OS concepts.

Regards,
-rick-


John Browning <no_spam@_nospam.comwrote:

<snip>

My own advice would be simple however. Make all your code as
generic and reusable (and robust) as possible. 95% or more of almost any
program can be made this way but 95% of all programmers don''t understand
this fundamental rule.

Robust I can agree with. Reusable less so - because in my experience,
the more reusable and generic you make it, the more complex it has to
be in order to accomplish the one task you have at hand. I often find
that I then never reuse the component in question, having gone to all
the trouble of making it reusable. These days, I build things in a less
reusable way until I can see that I''ve got code which *could* be reused
with a bit of a tweak. At that point with the appropriate unit tests in
place, it''s usually not too hard to make the changes while keeping the
original use working.

If you know for sure that you actually need the code to be generic from
the start, that''s a different matter of course.

This is often known as "YAGNI": "You Ain''t Gonna Need It"

See http://c2.com/xp/YouArentGonnaNeedIt.html or
http://en.wikipedia.org/wiki/You_Ain''t_Gonna_Need_It

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


这篇关于阅读优秀的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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