g***p 发帖数: 139 | 1 都是deferring some implementation to subclass.
Template多了点algorithm structure,
看了head first dp有点困惑。谢 |
g*****g 发帖数: 34805 | 2 factory stresses on interface, you have the same interface and pluggable
implementations, thus caller can be unaware of implementation.
Example, DB driver, you want to use one new DB, you have to have a new
driver
that implements the interface.
template stress on using same operation on different data type.
You are implementing a generic operation, most useful for collection
opertations like insert/delete/sort in STL.
【在 g***p 的大作中提到】 : 都是deferring some implementation to subclass. : Template多了点algorithm structure, : 看了head first dp有点困惑。谢
|
g***p 发帖数: 139 | 3 fatory - subclass decide which concrete class to create.
template - use delegation decide which behavior to use
nod. 每个pattern都不难理解,放在一起就有点晕。
【在 g*****g 的大作中提到】 : factory stresses on interface, you have the same interface and pluggable : implementations, thus caller can be unaware of implementation. : Example, DB driver, you want to use one new DB, you have to have a new : driver : that implements the interface. : template stress on using same operation on different data type. : You are implementing a generic operation, most useful for collection : opertations like insert/delete/sort in STL.
|
L*********r 发帖数: 92 | 4 factory method pattern: it is a creational pattern. it is used to seperate
the class instantiation from the caller. so the caller can get the object
instance without know or refer to the concrete class.
template method pattern: it is a behavior pattern. it defines the skeleton
of business logic in the abstract class. the subclass implements the
business logic following the skeleton. |
m******t 发帖数: 2416 | 5
Almost all the design patterns are about deferring/delegating something to
somebody else. It is the "why" and "how" that make them different.
【在 g***p 的大作中提到】 : 都是deferring some implementation to subclass. : Template多了点algorithm structure, : 看了head first dp有点困惑。谢
|
O*******d 发帖数: 20343 | 6 template是C++语言的一部分, factory不是。 |
m******t 发帖数: 2416 | 7
This "template" is not that "template". 8-)
【在 O*******d 的大作中提到】 : template是C++语言的一部分, factory不是。
|
q****m 发帖数: 153 | 8 haha
【在 O*******d 的大作中提到】 : template是C++语言的一部分, factory不是。
|