Python版 https://github.com/faif/python-patterns/blob/master/creational/abstract_factory.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ *What is this pattern about? In Java and other languages, the Abstract Factory Pattern serves to pr…
Small The first rule of functions is that they should be small.The second rule of functions is that they should be smaller than that.Functions should hardly ever be 20 lines long. Blocks and indenting This implies that the blocks within if statements…
工厂模式主要用来封装对象的创建,有3种分类:简单工厂(simple factory).工厂方法(factory method).抽象工厂(abstract factory). 简单工厂包括3种组成元素:抽象产品.具体产品.具体工厂(简单工厂),结构图如下: C++实现: //抽象产品 class Car { public: ; }; //具体产品 class Audi : public Car { public: string getDescription() { return "Audi&qu…