Design Pattern

1. Separate what changes from what stays the same
2. programming to an interface, not an implementation
3. favor composition over inheritance
4. stive for loosely coupled designs between Object that interact.
5. class should be open for extension, but close for modification.
6. Principle of least knowledge-talk only to your immediate firends.
7. Don't call us, we'll call you!
8. A class should have only one reason to change.

The Strategy pattern :
defines a family of algorithms, encapsulates each one, and make them interchangeable.
Strategy lets thes algorithm vary independently from clents that use it.
The Observer Pattern :
define a one-to-many dependency between objects
so that when one object changes state, all of it's dependents are notified and updated automatically


The Decorator Pattern :
attaches additional reponsibilities to an object dynamically.
Decorator privide a fiexible alternative to subclassing for extending functionality.

The Factory Method pattern :
define an interface for creating an object, but let subclasses decide which class to instantiate.
Factory Method lets a class defer instantiation to subclass.

The Abstract Factory :
provide a interface for creating families of related or dependent objects, without specifying their concrete classes.
The Singleton Pattern :
ensures a class can have only one instance,and have global point of access of it.

The Command Pattern :
encapsulate a request as a object,thereby let you to parameterize other objects with different requests,
queue or log request,and support undo operation.
The Adapter Pattern :
converts the interface of a class into another interface the clients expect.
Adapter lets classes work tegother that couldn't otherwise because of incompatible interface.
The Facade Pattern :
provide a unified interface to a set of interfaces in a subsystem.
Facade defines a high-level interface that make the subsystem easy to use.
The Template Method Pattern :
define a skeleton of a algorithm in a method, deferring some step to subclass.
Template Method lets subclass redine certain steps of an algorithm without changing the agorithem structure.
The Iterator Pattern :
provides a way to access the elements of an aggregate object sequentially exposing the underlying represetation.
The Composite Pattern :
allow you to composite objects into tree structures to represent part-whole hierarchies.
Composite lets clients treat individual objects and compositions of object uniformly.
The State Pattern :
allows an object to alter its behavior when its internal state changes.
The object will appear to change its class.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值