1. Ch4. The Factory Pattern
Head First Design Patterns
2014/04/24
vicall@Qlync Inc.
1
2. OO Principles - ch1~3
Encapsulate what varies.
Favor composition(合成) over inheritance(繼承)
Program to interface, not implementations.
Strive for loosely coupled designs between objects
that interact.
Classes should be open for extension but closed for
modification.
2
10. The Factory Method Pattern defines an interface for creating
an object, but lets subclasses decide which class to instantiate.
Factory Method lets a class defer instantiation to subclasses.
10
12. –Ch4. The Factory Pattern
[ Dependency Inversion Principle ]
顛覆依賴守則
!
“Depend upon abstractions. Do not depend upon
concrete classes.”
依賴抽象類別,不要依賴具象類別。
12
15. The Abstract Factory Pattern provides an interface for
creating families of related or dependent objects without
specifying their concrete classes.
15
20. OO Principles - ch1~4
Encapsulate what varies.
Favor composition(合成) over inheritance(繼承)
Program to interface, not implementations.
Strive for loosely coupled designs between objects that interact.
Classes should be open for extension but closed for modification.
Depend upon abstractions. Do not depend upon concrete
classes.
20