中山靖王……
星期一, 02月 5th, 2007汉景帝有14个儿子,汉景帝的儿子中山靖王刘胜有120多个儿子,然后刘备是他的后裔,不知道是哪个儿子生的,汗~。
汉景帝有14个儿子,汉景帝的儿子中山靖王刘胜有120多个儿子,然后刘备是他的后裔,不知道是哪个儿子生的,汗~。
简言之,Class和Object就是概念和实体的关系。
An object will always have four important facets:
1. it’s own identity (This might only be its address in memory.);
2. the attributes of its class (usually static) and values for those attributes (usually
dynamic);
3. the behavior of its class (the implementor’s view);
4. the published interface of its class (the user’s view).
Riel举了两个real world example:一个是 alarm clock,另一个是 automobile(汽车).
比如说automobile,汽车可以说都有一个public interface,你不必关心它的具体实现。不必担心会开宝马,却不会开奔驰。
Riel提出的建议是
Heuristic 2.1[信息隐藏]
All data should be hidden in its class.
也就是所有的数据成员应该是private的,对外只提供一个public interface,用get/set方法去访问数据。信息隐藏的好处在于实现改变了,接口没有改变,则对类的使用没有丝毫影响。
Q:但是这会带来性能上的损耗.
A:"我们应该忘记那些琐屑的效率提升,因为在97%的场合,不成熟的优化是万恶之源。"
–Donald Knuth
对性能的担忧还为时尚早,在最后阶段我们才应该去找真正的性能瓶颈。
接口设计的核心在于“这个类需要隐藏什么”。有时候它可以帮助我们做出好的设计决策。
至理。
Section 1.2. Accidental Versus Essential Complexity
"No Silver Bullet." –Frederick Brooks
There are two types of complexity feeding the software crisis: accidental complexity and essential complexity.
- 1. 软件的规模.Software applications, for their size, are the most complex entities that humans build.
- 2. 软件的难以量化.Software is intangible[难以明了的] and, for the most part, invisible.
- 3. 软件需求经常变化要求其扩展性.Software does not wear out[磨损] in the traditional sense of machinery with moving parts wearing out. However, software is constantly being used in ways its authors never expected (often uncovering errors), and end users are constantly demanding extensions to their software.
今天用eMule下来了 Object Oriented Design Heuristics (中文名“OOD启思录”),Code Complete 中大力推荐这本书,应该还不错,用的是 Effective C++ 那种风格,我喜欢:)
决定写一下读书笔记,也监督自己每天至少读一个section
Chapter 1. The Motivation[动机] for Object-Oriented Programming
Section 1.1. Revolutionists[革命家],Evolutionists[进化论者],and the Object-Oriented Paradigm
对于面向对象的设计有两种看法:一种比较激进(Revolutionists),主张原来的软件设计方法本身就是不对的,另一种则是Evolutionists,正如作者所说
"A software crisis does not come about because we are incorrectly developing software. A software crisis comes about because our paradigm of programming is no longer sufficient to handle the complexity of problems we are asked to solve."
采用面向对象的设计方法是因为问题复杂度所带来的危机。在只有8条指令,1K的内存机器上用0,1代码写程序没有问题,那也是一个合适的范型,但在现在的PC机上呢?
采用面向对象范型的最主要原因是"it allows designers more closely to model the real world".
现实世界是一种分散式(decentralized)的结构。"There is no central control mechanism to which everyone reports, gets orders,fulfills them, and returns for more work. "
结构化方法则是建立在中心式控制的基础上的。
分散式的结构有很多优点。"The strength of a decentralized architecture is the fact that any one problem will affect one area of the application, which, in a good design, will be loosely coupled to the other areas of the application. This limits the impact of change on our system should there be a problem with one application area, or should we wish to extend the same."简言之,好的设计应该是松耦合的.
So,try to think in a decentralized fashion, rather than follow the typical centralized control of structural approach.
准备清理机器,把一些软件换成绿色的,以下是些常用软件的清单
KMPlayer: 用了一段时间后就决定彻底抛弃暴风影音了,尤其喜欢Ctrl-Alt-A保存屏幕截图^o^,当然还有其他很强大的功能,也有绿色版的
Firefox: 曾经转战3个浏览器(Opera,Maxthon,Firefox)Opera属于疾速型,Maxthon其实也挺好用。不过,自从用了Firefox和某些强悍的插件以后就越来越离不开它了,尤其是某些插件相当的好用,准备换成绿色版的,这样就不用担心重装系统备份的问题了
TotalCommander: 强悍的文件管理器。现在用了是一个绿色增强版,带了很多有用的小工具(Autorun,UninstallAll…)
GreatNews: Green RSS reader
Fterm: 这个本来就是绿色的
eMule: 这个好像没有绿色版的,最近用eMule搜电子书,马上就搜到了(也不用满世界去找了)。此外,相当欣赏VeryCD的模式,在VeryCD上下的电影一般都是高品质的,把自己的机器改成HighID后速度也有了质的提升,从此也就彻底抛弃BT了。
WinKey: 自定义快捷键的,挺好用,不知道有没有绿色版的。
UltraEdit: 这个用的其实不多,最好用的就是在多个文件中查找了。
To Be Continued ……
- It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch[新纪元] of belief, it was the epoch of incredulity[怀疑], it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to heaven, we were all doing direct the other way – in short, the period was so far like the present period, that some of its noisiest authorities[权威] insisted on its being received, for good or for evil, in the superlative degree of comparison only.
- Charles Dickens, A Tale of Two Cities
English novelist (1812 – 1870)
今天晚上看这部98年的电影,发现PB中的马宏了,演一位空军上校hoho~。


黑帮老大 Abruzzi则演一位俄罗斯宇航员,一样很cool的类型
A physician[医师], a civil engineer[土木工程师], and a computer scientist were
arguing about what was the oldest profession in the world. The physician
remarked, "Weil, in the Bible, it says that God created Eve from a rib[肋骨]
taken out of Adam. This clearly required surgery[手术], and so I can rightly
claim that mine is the oldest profession in the world." The civil engineer
interrupted, and said,"But even earlier in the book of Genesis, it states that
God created the order of the heavens and the earth from out of the chaos[混沌].
This was the first and certainly the most spectacular[惊人的] application of
civil engineering[土木工程]. Therefore, fair doctor, you are wrong: mine is the
oldest profession in the world." The computer scientist leaned back in her
chair, smiled, and then said confidently, "Ah,
but who do you think created the chaos?"