Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Design Pattern & UML  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 GOF<<design patterns>>读后感,请各位评
haibo



CJSDN高级会员


发贴: 322
积分: 71
于 2004-05-24 10:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
刚仔细研读了preface 和 他的那个“案例研究“和"abstract factory"
有以下感触:
真正理解了面向对象思想的特性
1。多态
2。继承
3。封装
感觉到"abstract factory“ (这个“模式“)是怎么推出来。
“广义上说,其实代码没有好坏之分,只有是否更易于扩充之说“
面向对象的技巧:面向接口编程
“系统先有责任,后来才有担当责任的对象产生,因此各人划分的责任不同,最后出来的对象也可能不同(条条道路通罗马)“
请各位批评一下。。


haibo edited on 2004-05-24 10:57


作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
wes109

以梦为马

CJSDN高级会员


发贴: 857
积分: 60
于 2004-05-24 11:17 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
就感了这么点?
楼主等于没说


wes109 edited on 2004-05-24 11:32


作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
ConnorLv





发贴: 38
积分: 10
于 2004-05-24 15:38 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这么经典的书,感慨这么几句就完了!
GOF都给你气死了!



作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
haibo



CJSDN高级会员


发贴: 322
积分: 71
于 2004-05-24 18:00 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
其实读了这么点,我就有一种不想继续读的感觉,因为我觉得“程序本来就应该这样写“,只不过是Gof把它反映出来了



作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2004-05-24 23:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Hehe, I have the same feeling.

patterns are 乾坤大挪移, OO principles are 九阳神功. Without 九阳神功, it's hard to get 乾坤大挪移.

原来这“乾坤大挪移”心法,实则是运劲用力的一项极巧妙法门,根本的道理,在于发
挥每人本身所蓄有的潜力。每人体内潜力原极庞大,只是平时使不出来,每逢火灾等等紧急
关头,一个手无缚鸡之力的弱者往往能负千斤。张无忌练就九阳神功后,本身所积蓄的力道
已是当世无人能及,只是他未得高人指点,使不出来,这时一学到乾坤大挪移心法,体内潜
力便如山洪突发,沛然莫之能御。
  这门心法所以难成,所以稍一不慎便致走火入魔,全由于运劲的法门复杂巧妙无比,而
练功者却无雄浑的内力与之相副。正如要一个七八岁的小孩去挥舞百斤重的大铁锤,锤法越
是精微奥妙,越会将他自己打得头破血流,脑浆迸裂,但若舞锤者是个大力士,那便得其所
哉了。以往练这心法之人,只因内力有限,勉强修习,变成心有余而力不足。



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
wes109

以梦为马

CJSDN高级会员


发贴: 857
积分: 60
于 2004-05-25 08:56 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
haibo wrote:
其实读了这么点,我就有一种不想继续读的感觉,因为我觉得“程序本来就应该这样写“,只不过是Gof把它反映出来了


老大,你也太牛了,偶对你的敬佩之情,犹如江水滔滔。。。

Gof的设计模式本来就是对前人经验的总结,还是重构也是

不过,不想继续读的感觉从来没有过,这本书一年多来一直躺在我枕边
经常拿起来翻翻

初读设计模式晦涩难懂
再读设计模式略有所得
又读设计模式倍感神清气爽,为其机巧所折服

回头再看
什么设计模式,什么OO,什么重构
并不是什么了不起的技术,大道致简,“本来就应该这样嘛”(让我想起那个哥伦布立鸡蛋的故事)

推而广之,这个世界上有多少是很了不起的发现? 但你发现了你就了不起,用心而已

文章本天成,妙手偶得之

注意:是妙手。。。
不是靠狗X运

原来这种发现需要深厚的功底和经验积累,不是谁随便睡睡觉就可以发现一种化学元素,叫:苯

所以说:学习和理解OO的思想,运用设计模式到实践中去,不断的去玩味,才能真正做到挥洒自如,才能有所提高,有所发现,才能有妙手!

下次我们再碰到楼主的时候就可以说:楼主英明,大师风范,内外皆修! Big SmileBig SmileBig Smile




作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:wes109]
haibo



CJSDN高级会员


发贴: 322
积分: 71
于 2004-05-25 09:46 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
wes109 wrote:
老大,你也太牛了,偶对你的敬佩之情,犹如江水滔滔。。。

Gof的设计模式本来就是对前人经验的总结,还是重构也是

不过,不想继续读的感觉从来没有过,这本书一年多来一直躺在我枕边
经常拿起来翻翻

初读设计模式晦涩难懂
再读设计模式略有所得
又读设计模式倍感神清气爽,为其机巧所折服

回头再看
什么设计模式,什么OO,什么重构
并不是什么了不起的技术,大道致简,“本来就应该这样嘛”(让我想起那个哥伦布立鸡蛋的故事)

推而广之,这个世界上有多少是很了不起的发现? 但你发现了你就了不起,用心而已

文章本天成,妙手偶得之

注意:是妙手。。。
不是靠狗X运

原来这种发现需要深厚的功底和经验积累,不是谁随便睡睡觉就可以发现一种化学元素,叫:苯

所以说:学习和理解OO的思想,运用设计模式到实践中去,不断的去玩味,才能真正做到挥洒自如,才能有所提高,有所发现,才能有妙手!

下次我们再碰到楼主的时候就可以说:楼主英明,大师风范,内外皆修! Big SmileBig SmileBig Smile


其实我不想读的原因有两条:

1。我觉得在读完preface,"案例研究”两篇后,经过对已作过项目的再思考,已知道面向对象的原则是什么,比喻一下就是floater所说的“运气方法”,使我长期以来(自从接触第一门面向对象语言C++到现在将近两年)的许多疑惑都揭开了,
我已学会“修炼内力的方法和途径”,我想把精力放在“内力的增高上”。
2。我觉得GOF在他的design patterns中对“招数”的推理方法上写得并不好,从第一个创建型模式“abstract factory”上已明显见拙,他的推理把“实际的推理”都颠倒过来了,
那个MazeGame例子,本来应该是接口先出来,他倒一上去把door ,wall,room实现类都订出来了,然后给了个createMaze()方法来演示abstract factory. 本来好好的思路到被他引得上下不接,正确的思维方法度反被他束缚。
当然,这也可能是它举的demo的缘故,并未仔细认真推理“招数”的形成,相反,“案例研究”--RTF编辑器的推理就很好。

要看模式,不如直接看他的“示例代码”为好,不接受它的“招数”的推理。
以上仅是个人愚见,请各位评评。




作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
wes109

以梦为马

CJSDN高级会员


发贴: 857
积分: 60
于 2004-05-25 10:34 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
haibo wrote:
要看模式,不如直接看他的“示例代码”为好,不接受它的“招数”的推理。


动机 -----推理-----> 实现(代码实例)

道不觉得他的推理过程有什么不好,过程本来就是发现问题-->分析问题-->解决问题

之所以不接受想来是因为已了解

对于最终的使用来讲,中间的过程的确不再重要
发现问题 ---> 分析 --->寻找到合适的模式 ---> 按模式实现

但这叫照搬!

照搬可以做好,但无法做到完美,要创意更难

新的问题不断出现,需要新的模式,中间的过程就变得非常重要

当然,这些事可能轮不到我们,自有那些大师去做
像我们这些普通人,普普通通的程序员,只要把口张好,张得大大的
等着那些大师把模式做好了扔出来,呶,接着

只要快速的用口叼住就好了

haibo wrote:
以上仅是个人愚见,请各位评评。


一个人的观点就叫个人观点,是不是愚见重要吗?
成长是一个过程,只要去思考了就好
回头看看,我们都会发现自己曾经犯了那么多可笑的错误

一个人不可能完美,但要去追求完美
追求完美就是不断改进自己
改进自己就需要发现错误,改正错误
连错误都不敢犯,怎么去改进?




作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
haibo



CJSDN高级会员


发贴: 322
积分: 71
于 2004-05-25 11:17 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

多隆(偶对你的敬佩之情,犹如江水滔滔。。。)worteBig SmileBig SmileBig Smile:
新的问题不断出现,需要新的模式,中间的过程就变得非常重要

依据OO原则行事,就会写出适合你自己项目的好代码来,这些好代码可以称
做自己的“模式“。

多隆worte:
当然,这些事可能轮不到我们,自有那些大师去做
像我们这些普通人,普普通通的程序员,只要把口张好,张得大大的
等着那些大师把模式做好了扔出来,呶,接着
只要快速的用口叼住就好了

“大师“门有他们的“模式“,我们有适合我们我们自己的好“模式“。




作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
wes109

以梦为马

CJSDN高级会员


发贴: 857
积分: 60
于 2004-05-25 12:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我一辈子都糊涂,做的最明智的事就是回复wes109的帖子 wrote:
依据OO原则行事,就会写出适合你自己项目的好代码来,这些好代码可以称
做自己的“模式“。

“大师“门有他们的“模式“,我们有适合我们我们自己的好“模式“。


此模式非彼模式也
因为,模式它有一定的标准。。。




作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
zyzhang

Explorer



发贴: 155
积分: 30
于 2004-05-25 17:56 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
The benefit i got from the design patterns is that they are encourage me to be aware and respect the OO principals on the design of the complex product. The ideas behind the design patterns are related to the design consideration of extensibility, resuability, and etc. These design elements are important when you build complex product from scratch.

Refactoring is XP term, and integrate in the daily development cycle of software process. Good refactoring can result in design patterns(if you can recognize them). This is XP way to compliment the lack of design consideration when you directly go into the coding. So, Refactoring and design patterns are related, and they all are derived from the OO Principles.

Most of the current development environment are built on the high levle of well-known framework. Generally, you give little consideration on the low level design consideration, all you effort are focus on the understanding of the framework and implementing business logic. So, in this case, few design patterns are fall into the developers' eyes.

Design patterns actually help me a lot in the past year. They help me be more sensitive on the problem context and consider using pattern to build the structure of related objects, even though sometime, it's better to make your own variation on the design pattern, but the idea is essentially the same. Also, design patterns are good communication method for the team.

I can imagine, one can ignore the design patterns if you have strong and deep understanding on the OO Principals, also you have good abstract ability and some best practices in your mind.but most of us are not, design patterns instead give us good description on the solution of the common problems.

......



作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:zyzhang]
haibo



CJSDN高级会员


发贴: 322
积分: 71
于 2004-05-26 10:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
zyzhang wrote:
The benefit i got from the design patterns is that they are encourage me to be aware and respect the OO principals on the design of the complex product. The ideas behind the design patterns are related to the design consideration of extensibility, resuability, and etc. These design elements are important when you build complex product from scratch.

Refactoring is XP term, and integrate in the daily development cycle of software process. Good refactoring can result in design patterns(if you can recognize them). This is XP way to compliment the lack of design consideration when you directly go into the coding. So, Refactoring and design patterns are related, and they all are derived from the OO Principles.

Most of the current development environment are built on the high levle of well-known framework. Generally, you give little consideration on the low level design consideration, all you effort are focus on the understanding of the framework and implementing business logic. So, in this case, few design patterns are fall into the developers' eyes.

Design patterns actually help me a lot in the past year. They help me be more sensitive on the problem context and consider using pattern to build the structure of related objects, even though sometime, it's better to make your own variation on the design pattern, but the idea is essentially the same. Also, design patterns are good communication method for the team.

I can imagine, one can ignore the design patterns if you have strong and deep understanding on the OO Principals, also you have good abstract ability and some best practices in your mind.but most of us are not, design patterns instead give us good description on the solution of the common problems.

......

昨晚花了我较长时间,读了你的这篇回复和你以前的一篇和floater的交流--“design patterns and refactoring"。 首先,我对您严谨的发帖原则表示尊敬,这确实是当前cjd论坛法帖典范,对一个问题的充足说明足见作者的郑重。

回去后,我重新细读了第一个模式abstract factory,作者确实给出了一个demo和详细地说明, 我只是觉得如果让我来解决这个MazeGame的problem的话,我可能有我自己的解法,也许用到了这个所谓的“abstract factory" 模式的"半条腿”,但是这样的解法却也遵循OO princple,当然随着extend这个解法,可能会形成一个完整的"abstract factory". 如果从来没有可能去用到这“半条腿”,突然去接受这个“整个家伙”,却觉得不自然,没有经历的问题,没有深刻理解他的巧妙 之处的人,也不可能在实际开发中实践应用它的“机会”。
所以我说这本书的“推理过程”不够好。

再一个就是我说的“先出现接口,后出现实现责任的对象”之说。 面对一个新的project,我们首先可能想象到的就是我们的“目标应用”--程序,要为我们作些什么, so 我们定义一些接口,随之在一步一步的细化时,我们可能寻找一个对象来充当这个责任,继儿也就出现了对象,随后定义这个对象需要完成这些操作而需要持有的数据,相应的在细化完整个系统之后,完整的BMD(Business Module Diagrame) 就随之浮现。这是个由最高级的抽象到最底层的实现的过程。

题外话:这种想法很符合现实,举个例子:想开个公司,你需要一个经理人,你定义个“接口”,凡是 满足这个接口的人就可以来应聘,这个对象也就出现了,他所有的“知识”就相当于类的“数据成员”,继而也就确定了,同样经理人再去聘人来组织一个公司,当然,你不用关心这些细节,你--“总裁”(软件中相当于客户)只要关心一个人做的事,那就是--“经理”。你不应该直接去找公关小姐,秘书,职员,主任,这些“现实”的人,你找来了也未必会适合“经理”的要求,经理也就未必会做出你期望的事情,而此时,你连你希望的事情是什么都不全面--多么可怕


话说回来,MazeGame确是不同的,wall,door,room实体类一开始就冒出来了,显然已经hardcode了好多东东。 这就是我说它的“颠倒”的思维方法。

但是,总体而言,并不因为这些小缺点而影响它正部书的不错。我觉得整部书的模式一上去对一个经验不多的人像我,就取读,去接受,会束缚思想,认识不到它的巧妙之处, 也就形不成“自己的东东”。在你思考了好久之后,突然的看看它,会觉得灵机突现,会认识到它的精深,这样才会“挥洒自如,游刃有余”。




作者 Re:GOF<<design patterns>>读后感,请各位评 [Re:haibo]
sankxuan



发贴: 0
积分: 0
于 2004-05-26 21:24 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我觉得很奇怪,有时候接口是在重构中不断的抽象出来的,
你看看test driven development这本书,还有martin 的重构
,你只所以这样说,我只能猜测你的面向对象的设计
经验不足




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923