posts - 37,comments - 7,trackbacks - 0
A factory method handles object creation and encapsulates it in a subclass. This decouples the client code in the superclass from the object creation code in the subclass.
1. A factory method is abstract so the subclasses are counted on to handle object creation.
2. A factory method returns a Product that is typically used within methods defined in the superclass.
3. A factory method isolates the client from knowing what kind of concrete Product is actually created.
4. A factory method may be parameterized(or not) to select among several variations of a product.
posted on 2005-08-11 16:02 Dave 阅读(123) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: