Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Quick Look About Design Pattern from CoolShell.cn by LTaoist 小组成员: 聂丰 莫宇诚 史欢 林培泳 陈晓.

Similar presentations


Presentation on theme: "A Quick Look About Design Pattern from CoolShell.cn by LTaoist 小组成员: 聂丰 莫宇诚 史欢 林培泳 陈晓."— Presentation transcript:

1 A Quick Look About Design Pattern from CoolShell.cn by LTaoist 小组成员: 聂丰 莫宇诚 史欢 林培泳 陈晓

2 Find all blog of this presetation in "http://coolshell.cn/?s=%E8%AE% BE%E8%AE%A1%E6%A8%A1%E 5%BC%8F"http://coolshell.cn/?s=%E8%AE% BE%E8%AE%A1%E6%A8%A1%E 5%BC%8F

3 A short Intro of CoolShell.cn About 陈皓 – 微博 @ 左耳朵耗子 –“15 年软件开发相关工作经验, 8 年以上项目和团队管理经验。 ” – 曾于 Amazon 中国任研发经理。 – 现在阿里巴巴核心系统专家组从事阿里核心系统和阿里云 ECS 相关的虚拟化平台的开发工作。 About 酷壳( CoolShell ) – 一个完全依靠个人建立的技术性 BLOG – 分享技术见闻,知识,趋势 – 颇有影响力的国内技术 blog 文章风格: – 用词准确,思维连贯,图文并茂,写作认真 => 可读性高 – 内容较新,很多新鲜观点,容易看到另一面的思维 – 联系实际,结合代码实现 => 务实讲求干货 – 有说服力

4 #0 如此理解面向对象编程 复述 Rob Pike 对 《 Understanding Object Oriented Programming 》一文的 评论 问题: – 写一个程序,需要输出 一段关于操作系统的文 字: Unix 很不错, Windows 很差 输出 Unix is good os.name = ? 输出 Windows is bad 结束 开始 unix windows

5 "Hacker Solution" 用面向对象的编程方式一步一步地进化这 个代码。

6 过程化的方案

7 幼稚的面向对象编程

8

9 问题 这段代码没有消除 if 语句 代码的 “logic bottleneck” (逻辑瓶颈): – 如果你要增加一个操作系统的判断的话,你不 但要加个类,还要改那段 if-else 的语句 方案: Sophisticated

10 OO 大师的方案 注意其中的 Design Pattern – (使用 Hash 消除 if )

11

12 增加一个 Mac OS

13 好像哪里不对劲?

14 Rob Pike 的评论 Rob Pike – 当年在 Bell lab 里和 Ken 一起搞 Unix – 后来和 Ken 开发了 UTF-8 – 现在和 Ken 一起搞 Go 语言 “Local discussion focused on figuring out whether this was a joke or no” “For a while, we felt it had to be even though we knew it wasn't.” “ I'd call myself a hacker, at least in their terminology, yet my solution isn't there.” “Just search a small table! No objects required. ” –Trivial design –easy to extend, –cleaner than anything they present Their "hacker solution" is clumsy and verbose. –Everything else on this page seems either crazy or willfully obtuse. –The lesson drawn at the end feels like misguided( 误入歧途) epistemology (认知), not technological insight. “ 这些 OO 的狂热份子非常害怕数据,他们喜欢用多层的类的关系来完成一个本来只需要检索三行数据表的工作。 ” OOP 的本质就是 —— 对数据和与之关联的行为进行编程。便就算是这样也不完全对,因为: –Sometimes data is just data and functions are just functions

15 陈皓的评论

16 #1 : JDK 里的设计模式 JDK 里的设计模式 –http://coolshell.cn/articles/3320.html –JDK 中有关 23 个经典设计模式的示例 Learning Javascript Design Patter –http://addyosmani.com/resources/essentialjsd esignpatterns/book/ – 提及一些经典设计模式的 javascript 实现 –jQuery 中的设计模式

17 #2: 深入浅出单实例 Singleton 设计模式 实际版本: – 多线程环境? –Double-Check –Class Loader – 序例化 – 多个 Java 虚拟机 –volatile 变量 – 继承 – 代码重用

18 #3 从面向对象的设计模式看软件设计 起因: “ 那 23 个经典的设计模式和 OO 半毛钱关系 没有,只不过人家用 OO 来实现罢了 ……OO 的设 计模式思想和 Unix 的设计思想基本没什么差别 ” , 结果引来了一点点争议。 什么是模式 GoF 的 23 个设计模式(在其他场合) 关于 Unix 的设计模式( The Art Of Unix Programming ) 对 Amazon 中遇到的 SOA 式架构的讨论

19 #4 如何写出无法维护的代码 说了一下常见的 “ 糟糕代码 ” – 程序命名 – 伪装欺诈 – 文档和注释 – 程序设计 – 混乱你的代码 – 测试 – 其它

20 #5 一些软件设计的原则 简单地介绍一些常见的软件设计原则 –Don’t Repeat Yourself (DRY) –Keep It Simple, Stupid (KISS) –Program to an interface, not an implementation –Command-Query Separation (CQS) –You Ain’t Gonna Need It (YAGNI) –Law of Demeter ( Principle of Least Knowledge ) – 面向对象的 S.O.L.I.D 原则 –Common Closure Principle ( CCP ) – 共同封闭原则 –Common Reuse Principle (CRP) – 共同重用原则 –Hollywood Principle – 好莱坞原则 –High Cohesion & Low/Loose coupling & – 高内聚, 低耦合 –Convention over Configuration ( CoC ) – 惯例优于配置原则 –Separation of Concerns (SoC) – 关注点分离 –Design by Contract (DbC) – 契约式设计 –Acyclic Dependencies Principle (ADP) – 无环依赖原则

21 #6 那些炒作过度的技术和概念 StackExchange.com 上有一个贴子在评论 着最近 20 年来被炒作过度的技术,对于出 现的结果,大多数赞同,也有一些不赞同。 –Unified Modeling Language (UML) –Sharepoint –eXtensible Mark-up Language (XML) – 。。。

22 Thanks


Download ppt "A Quick Look About Design Pattern from CoolShell.cn by LTaoist 小组成员: 聂丰 莫宇诚 史欢 林培泳 陈晓."

Similar presentations


Ads by Google