摘要: 工厂的好处常见的工厂模式有三个:简单工厂(Factory)、工厂方法(Factory Method)、抽象工厂(Abstract Factory)。如果按目标分类它们都是属于创建型(Creational Pattern)《scala编程》里提到两个工厂的优点1. 将对象的创建集中化 好的代码的终极目标是:易维护,易扩展,易复用,易使用。但如果代码里new一个类,new得到处都是,new得五花八门那肯定是灾难。 所以要统一集中的使用一种方式,这就是所谓的易维护,易复用。2. 隐藏对象实际代表的类的细节 这里可以理解为初始化类的细节。也就是说,使客户更容易的理解和使用。这就是易用 由于隐藏了细节, 阅读全文
posted @ 2012-12-11 21:21 倚楼无语F5 阅读(460) 评论(0) 推荐(0)
摘要: The Uniform Access Principle was put forth by Bertrand Meyer. It states "All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation." This principle applies generally to object-o 阅读全文
posted @ 2012-12-11 18:04 倚楼无语F5 阅读(917) 评论(0) 推荐(0)