mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-23 04:16:02 +03:00
25 lines
485 B
Go
25 lines
485 B
Go
package abstractfactory
|
|
|
|
func getMainAndDetail(factory DAOFactory) {
|
|
factory.CreateOrderMainDAO().SaveOrderMain()
|
|
factory.CreateOrderDetailDAO().SaveOrderDetail()
|
|
}
|
|
|
|
func ExampleRdbFactory() {
|
|
var factory DAOFactory
|
|
factory = &RDBDAOFactory{}
|
|
getMainAndDetail(factory)
|
|
// Output:
|
|
// rdb main save
|
|
// rdb detail save
|
|
}
|
|
|
|
func ExampleXmlFactory() {
|
|
var factory DAOFactory
|
|
factory = &XMLDAOFactory{}
|
|
getMainAndDetail(factory)
|
|
// Output:
|
|
// xml main save
|
|
// xml detail save
|
|
}
|