Software Design Principle

There are lots of design patterns,but the most important thing you should know the the principle of design.All of the patterns are followed those principles.

1.SRP -  Single Responsible Principle

One class should has the single responsible, we should avoid the same responsibiltes spreaded into defferent classed and avoid one class do to much responsibility.

2.ISP - Interface Segregation Principle

If one class has reference to anther one, it's better segregate them by interface rather than inheritance because the subclass sometimes don't need  some functions in base class.

3.DIP - Dependence Inversion Principle

Programming on the interface rather than the concrete  class.The high level class communicates with the lower level with interface.As the interface is abstract  so it  relative stable.

4.OCP - Open  Closed Principle

Open for the extension and closed for the modify. A class should be opened and extensible, but when you want to extend the function of this class, it's better don't modify the exist class or you shouldn't affact exist function.

5.LSP - Liskov  Substitution Principle

sub types must be substitutable for their base types.

Above all,Pls understand those principle carefullly, and you will get more discoveries and surprises.

猜你喜欢

转载自luhantu.iteye.com/blog/1749744