您的位置:首页 > 移动开发 > Objective-C

面向对象的设计准则--Principles Of Object-Oriented Design

2007-08-07 11:27 381 查看
开放封闭原则 Software entities (classes, modules, etc) should be open for extension, but closed for modification. 软件实体像类,模块等应该对扩展是开放的,而对修改是封闭的。
里氏替换原则 Derived classes must be usable through the base class interface without the need for the user to know the difference.
依赖倒置原则 Details should depend upon abstractions. Abstractions should not depend upon details.
1 public interface IProgrammer
2
7 public class Programmer : IProgrammer
8
13 public abstract class ManagerBase
14
18 public class Manager : ManagerBase
19
26 public class Client
27 public interface IPrinter
2
8 public class Printer : IPrinter
9
24
25 public interface IPrinter2
26
32 public interface IMeasure
33
37 public class Printer2 : IPrinter2
38 {
39 public string Read()
40 {
41 return null;
42 }
43
44 public void Write(string content)
45 {
46 }
47
48 public void Monitor(IMeasure format)
49 {
50 }
51 }
...

http://www.tek271.com/articles/pood/PrinciplesOfOOD.java.html
http://ootips.org/ood-principles.html
http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: