概括: 利用抽象的Interface作为返回值,使得用户不需要知道具体使用类的类型,而只需要使用通过Factory方法返回的Interface的类型.
关键字: interface, hide which class to instantiate from user
重点: Factory方法返回的是一个Interface类型, 该类型对用户隐藏了具体的实现类.
类图:
简单例子:
JDK中的Collection的接口和toString这个方法就是最好的Factory的例子.(参见 <Design Pattern In Java>)