Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Object Orientation Is a Hoax

runninghack
September 27, 2012

Object Orientation Is a Hoax

School of Information Science and Engineering
University of Jinan

runninghack

September 27, 2012
Tweet

More Decks by runninghack

Other Decks in Technology

Transcript

  1. 一些对OOP的评价(一) • Alexander Stepanov(STL之父):面向对象是 个骗局 • >1. I find OOP

    technically unsound. • >2. I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting - saying that everything is an object is saying nothing at all. • >3. I find OOP methodologically wrong. It starts with classes. It is as if mathematicians would start with axioms. 策略?状态? AOP?!
  2. OOP五大基本原则 • 单一职责原则(SRP) • 开放封闭原则(OCP) • 里氏替换原则(LSP) • 依赖倒置原则(DIP) •

    接口隔离原则(ISP) • 如果知道了每个原则对应解决的是什么问题,就可以更好 的理解OOP! 会用Java写程序并不意味着你会OOPL,懂得五大原则和一些 实现的方法才能说会OOPL。
  3. DIP:依赖倒置原则 定义: • A. 高层模块不应该依赖于低层模块,二者都应该依赖于抽 象。 • B. 抽象不应该依赖于细节。细节应该依赖于抽象。 和OCP的关系:

    • DIP 原则和 OCP 原则是目标和手段的关系。OCP 是目标, DIP 是手段。要想实现 OCP ,必须坚持 DIP 。违反了 DIP , 则不可能达到 OCP 要求。 对比: • LSP原则 OCP目标 DIP手段
  4. 其实我也不知道什么时候用 • Design is a wicked problem • Design is

    a sloppy process (Even if produces a tidy result) • Design is about tradeoffs and priorities • Design involves restrictions • Design in nondeterministic • ……
  5. 不要有这些态度 • 不要为了模式而模式 • 只要遵循基本设计原则就可以 • 编程语言都是浮云、思想最重要 • 编程工具都是浮云、思想最重要 •

    受“无招胜有招”文化熏陶太久,导致大家还没等学会招呢, 先奔无招去了: 延伸阅读:思想最重要?(ramiel.blogbus.com)