Coding Honor Logo

CODING HONOR

programming and critical thinking

如来之由来

“阿耨楼陀,实相并不是文字言语或意念知识所能表达得到的。只有禅定所生的智慧,才可以使我们确认到实相的真绪。阿耨楼陀,你是没法用言语来表达芒果的真正味道,并让他知道是怎样的。我们只有从亲身的体验,才可以掌握到真相。这也是我时常劝比丘们不要在理论上浪费宝贵的时间,而应多实习彻观一切的原因。

“一切法的性体,都是‘如是’的,这是万法之妙性。莲花从‘如是’而生起,阿耨楼陀从‘如是’而起,乔达摩也从‘如是’而生。我们可以称所有从‘如是’生起者为‘如来’,一切法从‘如是’生起,又将回归何处?一切法都回归到‘如是’。归到‘如是’,也可称为‘如去’。其实,一切法都没从哪儿来或到哪儿去,因为它们的本性‘如是’。阿耨楼陀,‘如是’的更正确意思,应该是‘无从来者’和‘无所去者’。阿耨楼陀,从现在开始,我将叫自己‘如来’。我喜欢这名词,因为它可以避免因分别而生起的字眼儿,像‘我’或‘我的’。”

阿耨楼陀微笑说道:“我们都知道我们全都从‘如是’而生起,但我们会只让你专用‘如来’这个名号。每次当我们如此称呼你的时候,便会提醒我们所有众生都具有这无始无终的‘如来’本性。”

高质量设计的十一个特征

如果你是一个愿意雕琢自己代码的开发者,那么你肯定会在每次开发结束以后对其进行一定的总结。因为你知道,从中得出的经验教训将会对下次的开发工作有着非常好的指导意义。当然我也不例外,并时常自满于这四五年来的经验积累。但当这些非常自我的开发经验遇到《代码大全》作者总结的高质量设计特征时,在短暂的於我心有戚戚焉之后,我陷入了一种无奈——到底还有多少知识的宝藏藏匿于整个知识的疆界中,而我却茫然不知。

从自我批评的角度来看,类似的问题都可以简单的归结于读书不多不广。但客观上来讲,我们其实也可以为自己找一些借口。步入现代社会以后,人类知识积累的速度越来越快。随着知识的疆界变得越来越大,如果我们在知识获取方式上没有一次革新的话,总有一天我们会惊诧于目前获取及使用知识的效率是如此之低效。也许脑机接口将是一个解决该问题的突破口,不过在类似技术还没有成熟起来之前,一些朴素的刻苦读书的道理貌似是目前唯一的解决方案。

看来我也能写这种翻译腔十足、内容空洞无物以及面向程序员的小品文了(重灾区在这里)。回到正题,实际上下面的关于高质量设计的11个特征应该是本文的重点(内容来自《代码大全》):

  1. 最小的复杂度(Minimal complexity) 设计的首要目标就是要让复杂度最小。要避免做出“聪明的”设计,因为“聪明的”设计常常都是难以理解的。应该做出简单且易于理解的设计。如果你的设计方案不能让你在专注于程序的一部分时安心的忽视其他部分的话,这一设计就没有什么作用了。

  2. 易于维护(Ease of maintenance) 易于维护意味着在设计时为做维护工作的程序员着想。请时刻想着这些维护程序员可能会就你写的代码而提出的问题。把这些程序员当成你的听众,进而设计出能自明的(self-explanatory)系统来。

  3. 松散耦合(Loose coupling) 松散耦合意味着在设计时让程序的各个组成部分之间关联最小。通过应用类接口中的合理抽象、封装性及信息隐藏等原则,设计出相互关联尽可能最小的类。减少关联也就减少了集成、测试与维护的工作量。

  4. 可扩展性(Extensibility) 可扩展性是说你能增强系统的功能而无须破坏其底层结构。你可以改动系统的某一部分而不会影响到其他部分。越是可能发生的改动,越不会给系统造成什么破坏。

  5. 可重用性(Reusability) 可重用性意味着所设计的系统的组成部分能在其他系统中重复使用。

  6. 高扇入(High fan-in) 高扇入就是说让大量的累使用某个给定的类。这意味着设计出的系统很好的利用了在较低层次上的工具类(utility classes)。

  7. 低扇出(Low fan-out) 低扇出就是说让一个类里少量或适中的使用其他的类。高扇出(超过约7个)说明一个类使用了大量其他的类,因此可能变得过于复杂。研究发现,无论考虑某个子程序调用其他子程序的里量,还是考虑某个类使用其他类的量,低扇出的原则都是有益的(Card and Glass 1990; Basili, Briand, and Melo 1996)。

  8. 可移植性(Portability) 可移植性是说应该这样设计系统,使它能很方便的移植到其他环境中。

  9. 精简型(Leanness) 精简型意味着设计出的系统没有多余的部分(Wirth 1995, McConnnell 1997)。伏尔泰曾说,一本书的完成,不在它不能加入任何内容的时候,而在不能再删去任何内容的时候。在软件领域中,这一观点就更正确,因为任何多余的代码也需要开发、复审和测试,并且当修改了其他代码之后还需要重新考虑它们。软件的后续版本也要和这些多余代码保持向后兼容。要问这个关键的问题:“这虽然简单,但把它加进来之后会损害什么呢?”

  10. 层次性(Stratification) 层次性意味着尽量保持系统各个分解层的层次性,使你能在任意的层面上观察系统,并得到某种具有一致性的看法。设计出来的系统应该能在任意层次上观察而不需要进入其他层次。

  11. 标准技术(Standard techniques) 一个系统所依赖的外来的、古怪的东西越多,别人在第一次想要理解它的时候就越是头疼。要尽量用标准化的、常用的方法,让整个系统给人一种熟悉的感觉。

放弃那些无聊又浪费时间的小品文吧,多读领域内的经典书籍,无论是技能还是逼格都会得到极大的提升。

最后列上自己最近在读的两本书。与君共勉!

《代码大全》

《数据结构与算法分析 – C语言描述》

2008 Baccalaureate Service by Drew Gilpin Faust

“Life is long. There is always time for Plan B. But don’t begin with it.”

In the curious custom of this venerable institution, I find myself standing before you expected to impart words of lasting wisdom. Here I am in a pulpit, dressed like a Puritan minister — an apparition that would have horrified many of my distinguished forebears and perhaps rededicated some of them to the extirpation of witches. This moment would have propelled Increase and Cotton into a true “Mather lather.” But here I am and there you are and it is the moment of and for Veritas.

You have been undergraduates for four years. I have been president for not quite one. You have known three presidents; I one senior class. Where then lies the voice of experience? Maybe you should be offering the wisdom. Perhaps our roles could be reversed and I could, in Harvard Law School style, do cold calls for the next hour or so.

We all do seem to have made it to this point — more or less in one piece. Though I recently learned that we have not provided you with dinner since May 22. I know we need to wean you from Harvard in a figurative sense. I never knew we took it quite so literally.

But let’s return to that notion of cold calls for a moment. Let’s imagine this were a baccalaureate service in the form of Q & A, and you were asking the questions. “What is the meaning of life, President Faust? What were these four years at Harvard for? President Faust, you must have learned something since you graduated from college exactly 40 years ago?” (Forty years. I’ll say it out loud since every detail of my life — and certainly the year of my Bryn Mawr degree — now seems to be publicly available. But please remember I was young for my class.)

In a way, you have been engaging me in this Q & A for the past year. On just these questions, although you have phrased them a bit more narrowly. And I have been trying to figure out how I might answer and, perhaps more intriguingly, why you were asking.

Let me explain. It actually began when I met with the UC just after my appointment was announced in the winter of 2007. Then the questions continued when I had lunch at Kirkland House, dinner at Leverett, when I met with students in my office hours, even with some recent graduates I encountered abroad. The first thing you asked me about wasn’t the curriculum or advising or faculty contact or even student space. In fact, it wasn’t even alcohol policy. Instead, you repeatedly asked me: Why are so many of us going to Wall Street? Why are we going in such numbers from Harvard to finance, consulting, i-banking?

There are a number of ways to think about this question and how to answer it. There is the Willie Sutton approach. You may know that when he was asked why he robbed banks, he replied, “Because that’s where the money is.” Professors Claudia Goldin and Larry Katz, whom many of you have encountered in your economics concentration, offer a not dissimilar answer based on their study of student career choices since the seventies. They find it notable that, given the very high pecuniary rewards in finance, many students nonetheless still choose to do something else. Indeed, 37 of you have signed on with Teach for America; one of you will dance tango and work in dance therapy in Argentina; another will be engaged in agricultural development in Kenya; another, with an honors degree in math, will study poetry; another will train as a pilot with the USAF; another will work to combat breast cancer. Numbers of you will go to law school, medical school, and graduate school. But, consistent with the pattern Goldin and Katz have documented, a considerable number of you are selecting finance and consulting. The Crimson’s survey of last year’s class reported that 58 percent of men and 43 percent of women entering the workforce made this choice. This year, even in challenging economic times, the figure is 39 percent.

High salaries, the all but irresistible recruiting juggernaut, the reassurance for many of you that you will be in New York working and living and enjoying life alongside your friends, the promise of interesting work — there are lots of ways to explain these choices. For some of you, it is a commitment for only a year or two in any case. Others believe they will best be able to do good by first doing well. Yet, you ask me why you are following this path.

I find myself in some ways less interested in answering your question than in figuring out why you are posing it. If Professors Goldin and Katz have it right; if finance is indeed the “rational choice,” why do you keep raising this issue with me? Why does this seemingly rational choice strike a number of you as not understandable, as not entirely rational, as in some sense less a free choice than a compulsion or necessity? Why does this seem to be troubling so many of you?

You are asking me, I think, about the meaning of life, though you have posed your question in code — in terms of the observable and measurable phenomenon of senior career choice rather than the abstract, unfathomable and almost embarrassing realm of metaphysics. The Meaning of Life — capital M, capital L — is a cliché — easier to deal with as the ironic title of a Monty Python movie or the subject of a Simpsons episode than as a matter about which one would dare admit to harboring serious concern.

But let’s for a moment abandon our Harvard savoir faire, our imperturbability, our pretense of invulnerability, and try to find the beginnings of some answers to your question.

I think you are worried because you want your lives not just to be conventionally successful, but to be meaningful, and you are not sure how those two goals fit together. You are not sure if a generous starting salary at a prestigious brand name organization together with the promise of future wealth will feed your soul.

Why are you worried? Partly it is our fault. We have told you from the moment you arrived here that you will be the leaders responsible for the future, that you are the best and the brightest on whom we will all depend, that you will change the world. We have burdened you with no small expectations. And you have already done remarkable things to fulfill them: your dedication to service demonstrated in your extracurricular engagements, your concern about the future of the planet expressed in your vigorous championing of sustainability, your reinvigoration of American politics through engagement in this year’s presidential contests.

But many of you are now wondering how these commitments fit with a career choice. Is it necessary to decide between remunerative work and meaningful work? If it were to be either/or, which would you choose? Is there a way to have both?

You are asking me and yourselves fundamental questions about values, about trying to reconcile potentially competing goods, about recognizing that it may not be possible to have it all. You are at a moment of transition that requires making choices. And selecting one option — a job, a career, a graduate program — means not selecting others. Every decision means loss as well as gain — possibilities foregone as well as possibilities embraced. Your question to me is partly about that — about loss of roads not taken.

Finance, Wall Street, “recruiting” have become the symbol of this dilemma, representing a set of issues that is much broader and deeper than just one career path. These are issues that in one way or another will at some point face you all — as you graduate from medical school and choose a specialty — family practice or dermatology, as you decide whether to use your law degree to work for a corporate firm or as a public defender, as you decide whether to stay in teaching after your two years with TFA. You are worried because you want to have both a meaningful life and a successful one; you know you were educated to make a difference not just for yourself, for your own comfort and satisfaction, but for the world around you. And now you have to figure out the way to make that possible.

I think there is a second reason you are worried — related to but not entirely distinct from the first. You want to be happy. You have flocked to courses like “Positive Psychology” — Psych 1504 — and “The Science of Happiness” in search of tips. But how do we find happiness? I can offer one encouraging answer: get older. Turns out that survey data show older people — that is, my age — report themselves happier than do younger ones. But perhaps you don’t want to wait.

As I have listened to you talk about the choices ahead of you, I have heard you articulate your worries about the relationship of success and happiness — perhaps, more accurately, how to define success so that it yields and encompasses real happiness, not just money and prestige. The most remunerative choice, you fear, may not be the most meaningful and the most satisfying. But you wonder how you would ever survive as an artist or an actor or a public servant or a high school teacher? How would you ever figure out a path by which to make your way in journalism? Would you ever find a job as an English professor after you finished who knows how many years of graduate school and dissertation writing?

The answer is: you won’t know till you try. But if you don’t try to do what you love — whether it is painting or biology or finance; if you don’t pursue what you think will be most meaningful, you will regret it. Life is long. There is always time for Plan B. But don’t begin with it.

I think of this as my parking space theory of career choice, and I have been sharing it with students for decades. Don’t park 20 blocks from your destination because you think you’ll never find a space. Go where you want to be and then circle back to where you have to be.

You may love investment banking or finance or consulting. It might be just right for you. Or, you might be like the senior I met at lunch at Kirkland who had just returned from an interview on the West Coast with a prestigious consulting firm. “Why am I doing this?” she asked. “I hate flying, I hate hotels, I won’t like this job.” Find work you love. It is hard to be happy if you spend more than half your waking hours doing something you don’t.

But what is ultimately most important here is that you are asking the question — not just of me but of yourselves. You are choosing roads and at the same time challenging your own choices. You have a notion of what you want your life to be and you are not sure the road you are taking is going to get you there. This is the best news. And it is also, I hope, to some degree, our fault. Noticing your life, reflecting upon it, considering how you can live it well, wondering how you can do good: These are perhaps the most valuable things that a liberal arts education has equipped you to do. A liberal education demands that you live self-consciously. It prepares you to seek and define the meaning inherent in all you do. It has made you an analyst and critic of yourself, a person in this way supremely equipped to take charge of your life and how it unfolds. It is in this sense that the liberal arts are liberal — as in liberare — to free. They empower you with the possibility of exercising agency, of discovering meaning, of making choices. The surest way to have a meaningful, happy life is to commit yourself to striving for it. Don’t settle. Be prepared to change routes. Remember the impossible expectations we have of you, and even as you recognize they are impossible, remember how important they are as a lodestar guiding you toward something that matters to you and to the world. The meaning of your life is for you to make.

I can’t wait to see how you all turn out. Do come back, from time to time, and let us know.

– Drew Gilpin Faust

Original link: 2008 Baccalaureate Service

Godzilla

影片的副标题应该叫:大哥(Godzilla)从良记。前方高能预警,没看的建议还是先去看电影吧。

剧情实在让人难以接受,这大哥绝对是奥特曼变的。剧中打完Muto,心想你们这些看热闹的愚蠢的人类该傻眼了吧,看我大哥分分钟钟秒了你们。万万没想到,我们的大哥就这么挥一挥衣袖的走了,入水姿势还挺华丽。请冷静的告诉我,这不是奥特曼这又是什么?!追了小半个地球,我们的大哥竟然就是为了打断一对苦命鸳鸯的激情一夜。另外,那个舌吻是什么意思,Muto拿着核弹往生殖器那里蹭这段又是个什么意思?

日本博士千叮咛万嘱咐说别用核弹让自然来做制衡,结果被我们将军毅然决然的拒绝了,毕竟以前用的是鞭炮嘛。可既然是用来做诱饵的,那至少也得保证诱饵没有那么容易就被拿去蹭自己吧。然后,现实立马就给了将军重重一击。这个时候将军猛然发现,完了完了炸弹还没关呢。本是为了引诱Muto出来解救市民,现在很可能市民会死于友军火力。哎,人类在这场神级别的怪兽斗争中果然是用来搞笑的。

算了,还是得说说本片优秀的地方吧,也不能老盯着槽点不放。

首先效果非常棒,我去UME看的,大哥嘶吼的场景确实震慑人心。影片一反以往怪兽神龙见首不见尾的习惯,让观众清晰的看到了神级怪兽的全貌,在我看来这也算是一种突破。Godzilla这部电影代表了一代人的回忆,相比Pacific Rim中的怪兽(虽然这是部机甲片),Godzilla明显抢眼多了。我小的时候看过前一个版本的Godzilla,在那个年代,看到这么大的一个怪兽就横空出现,那种震撼大人也觉得非凡更何况幼小的我。所以导演在大哥形象的改善上可能是有意为之,不再是单纯的破坏者,而变成了拯救者。片中也有暗示,称大哥为城市保卫者。看到这里,你还会对大哥只是单纯的觉得恐怖吗,难道没有感觉到略微变得可爱起来的转变吗?

另外人类战士背负使命跳入炼狱般的格斗现场,这场戏真的很好的营造了悲壮感。在明知极其危险且没有B计划的情况下,战士们毅然选择奔赴前方,他们是人类的英雄。文章前面所引用的海报就由这个场景而来,一道道划破天际的红线我觉得挺美的。

总体而言剧情虽然较弱,电影总体评分可能也不会太高,但是依旧值得一看。没看演员阵容,老白一出场那会儿真是颇感意外。不过毒师这次是单独行动,也不知道小粉最近在忙啥。

Spain’s First Match of 2014 World Cup

I didn’t do things like I should have, especially to start a World Cup. – Casillas

When a team loses a match it’s not just the performance of one single player, its a weakness in the total squad. – De Bosque

John Carmack Said

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren’t sure which way to do something, do it both ways and see which works better.

CodeSync

CMVC这个上古神兽网络上资料本来就非常少,更别提对应的Eclipse插件相关的文档记录了。为了找到CMVC在哪里保存着文件修改状态,扫描了整个工程目录,通过比对修改时间最终竟还真找到了。

最终成型的CodeSync客户端如下,JavaScript实现。

如烟往事不可捉摸

这几天在读章诒和的《往事并不如烟》,刚读完前几页就觉得眼界大开。原来在最困难的年代,也并非所有人的生活都是《夹边沟记事》中的那样。以前只知存在差距,但并不知其非常巨大。

读的过程中,一直有种挣扎的心理反复出现。一方面非常敬佩书中一些人,觉得这批人才是这个民族的传承与希望。另一方面,又怀疑这种强烈主观的叙述方式对于作品本身到底好吗?换句话说,这样写对前面那批人的故事的可信度会不会有影响?在可信度受到影响的情况下,原本产生的敬佩之情是不是应该,这都着实令我分心。

客观评价,我觉得章先生的这本书还是写的非常好的。文笔自不必说,单是这份记录,也会使那段历史不至于如烟般散去。即便有人觉得这是一个右派受害者的控诉,难免会有存在一些主观看法。不过,有些事,对就是对,错就是错,无论书写者立场如何都不能使其改变。多一份记录还能使我们有机会从字里行间读到一些历史,记录多了相互印证,更有助于我们还原历史的真实。更何况无论你境况好坏,只要受到迫害,那都是有权利控诉的。

但正如做人一般,人有格局大小之分,文章也有境界高低之别。特别是这种回忆类文章,如果真实性因为个人感情的代入而受到影响,那文章的境界就会大打折扣。而且章先生也是经历过文化大革命的人,应深知这文字上的是非之甚。梁文道对章的评价我就觉得挺中肯:“章诒和这个人的性格比较直率坦白,他写的文章非常有我,也就是说他很喜欢把自己怎么样被感动了、哭了这些东西都直接写进去,那大概我这个人性情比较孤僻,就比较冷漠一点,看到这样的文字就总觉得与我自己性情不太合。”

其实这方面我最欣赏两个人,一是杨显惠,一是唐德刚。杨显惠的《夹边沟记事》每篇故事都触目惊心,但他就能很好的保持自己与故事之间的距离,不煽情不代入不引导,让读者自行去体会这些文字后面的悲凉。科班出身的唐德刚就更是了得,为胡适写口述传记,即便有师生关系也能从中跳出来,客观的写出大师的局限性。格局境界立判高下。

如烟往事不可捉摸,但至少应尽力使之言之凿凿。这便是我读完此书后所学到的教训。