-> Very useful for the system integration when some other components have to be adapted by the existing system.
Adapter Design Pattern Structure
Classes:
- an interface for Target (class to which the non-adapted class should be adapted) : ITarget
- a class NonAdapted (does not implement ITarget)
- a class Adapter (has a field of type NonAdapted and implement ITarget using fuctionality from NonAdapter class)
- an interface ICommunicator - interface that contracts other classes to be a Communicator and gain the ability to communicate to an ITarget object
public interface ICommunicator
{
ITarget ObjectToTarget { get; set; }
void StartCommunication();
}
- a class Communicator : ICommunicator
Niciun comentariu:
Trimiteți un comentariu