1 / 22

A Quick Look About Design Pattern from CoolShell

A Quick Look About Design Pattern from CoolShell.cn. by LTaoist. 小组成员: 聂丰 莫宇诚 史欢 林培泳 陈晓. Find all blog of this presetation in " http://coolshell.cn/?s=%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F ". A short Intro of CoolShell.cn. About 陈皓 微博 @左耳朵耗子 “15年软件开发相关工作经验,8年以上项目和团队管理经验。”

eloise
Download Presentation

A Quick Look About Design Pattern from CoolShell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Quick Look About Design Patternfrom 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%E5%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很差 开始 os.name = ? unix windows 输出Windows is bad 输出 Unix is good 结束

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

  6. 过程化的方案

  7. 幼稚的面向对象编程

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

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

  10. 增加一个Mac OS

  11. 好像哪里不对劲?

  12. 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

  13. 陈皓的评论

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

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

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

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

  18. #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) – 无环依赖原则

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

  20. Thanks

More Related