I ran into a question on stackoverflow the other day that sort of shocked me. It was a piece of code, with the author asking why it wasn't a factory pattern. The thing that shocked me was that the pattern that everyone was agreeing was a factory meth…
Java 设计模式系列(二)简单工厂模式和工厂方法模式 实现了创建者和调用者的分离.分为:简单工厂模式.工厂方法模式.抽象工厂模式 简单工厂模式.工厂方法模式都很简单,就不详细介绍了. 一.简单工厂 public interface Car { public void run(); } public class Audi implements Car { public void run() { System.out.println(this.getClass().getSimpleName()…