Today learning another design pattern, adapter (Adapter) mode, which is a common direction, but with special requirements, is applied to this design pattern. Write here, think of a long time ago, have written an article "ASP." NET Adapter design mode (Adapter) http://www.cnblogs.com/insus/archive/2013/02/04/2891426.html, but does not seem to have the flavor of the adapter.
such as a system, the development of a variety of design permissions, but a certain, customer requests, requires a special permission to operate. Have to develop an adapter to have this special operation permission.
Use code to give an example.
Define the interface first:
When developing, we need to subdivide, read, write, delete ..., which produces a lot of subdivision classes:
Read:
Write:
By deleting:
And so on, here are the special requirements that allow some operators to have write and delete permissions, so a special adapter needs to be developed:
Client implementations:
Operation Result:
Design mode--Adapter (Adapter) mode