Adapter Mode and Facade Mode

Adapter pattern: Convert the interface of one class into the interface of another class that the client expects. Adapters allow otherwise incompatible classes to work together.
Use object composition to wrap the adaptee with a modified interface.
public class EnumerationIterator implements Iterator<Object>{
	Enumeration<Object>  enumeration;
	public EnumerationIterator(Enumeration<Object>  enumeration){
		this.enumeration = enumeration;
	}
	@Override
	public boolean hasNext() {
		return enumeration.hasMoreElements();
	}

	@Override
	public Object next() {
		return enumeration.nextElement();
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}
	
	
}



Facade Mode: Provides a unified interface for accessing a group of interfaces in a subsystem. The Facade pattern defines a high-level interface that makes the subsystem easier to use.
Facade pattern is used when you need to simplify and unify a large interface or a group of complex interfaces.


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326763136&siteId=291194637