1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00

finish if

This commit is contained in:
Xargin 2018-06-24 14:24:28 +08:00
parent 6764461de9
commit 81bd59d110
4 changed files with 36 additions and 1 deletions

View File

@ -48,6 +48,7 @@
* [5.5. Database和数据库打交道](ch5-web/ch5-05-database.md) * [5.5. Database和数据库打交道](ch5-web/ch5-05-database.md)
* [5.6. Ratelimit 服务流量限制](ch5-web/ch5-06-ratelimit.md) * [5.6. Ratelimit 服务流量限制](ch5-web/ch5-06-ratelimit.md)
* [5.7. Layout大型web项目分层](ch5-web/ch5-07-layout-of-web-project.md) * [5.7. Layout大型web项目分层](ch5-web/ch5-07-layout-of-web-project.md)
* [5.8. interface 和 table-driven 开发](ch5-web/ch5-08-interface-and-web.md)
* [5.9. 灰度发布和 A/B test](ch5-web/ch5-09-gated-launch.md) * [5.9. 灰度发布和 A/B test](ch5-web/ch5-09-gated-launch.md)
* [5.11. Load-balance负载均衡](ch5-web/ch5-11-load-balance.md) * [5.11. Load-balance负载均衡](ch5-web/ch5-11-load-balance.md)
* [第六章 分布式系统](ch6-cloud/readme.md) * [第六章 分布式系统](ch6-cloud/readme.md)

View File

@ -78,7 +78,7 @@ type OrderCreator interface {
如果我们正在做的是平台系统,需要由平台来定义统一的业务流程和业务规范,那么基于 interface 的抽象就是有意义的。举个例子: 如果我们正在做的是平台系统,需要由平台来定义统一的业务流程和业务规范,那么基于 interface 的抽象就是有意义的。举个例子:
TODOinterface 实现的 uml 图 ![interface-impl](../images/ch6-interface-impl.png)
平台需要服务多条业务线,但数据定义需要统一,所以希望都能走平台定义的流程。作为平台方,我们可以定义一套类似上文的 interface然后要求接入方的业务必须将这些 interface 都实现。如果 interface 中有其不需要的步骤,那么只要返回 nil或者忽略就好。 平台需要服务多条业务线,但数据定义需要统一,所以希望都能走平台定义的流程。作为平台方,我们可以定义一套类似上文的 interface然后要求接入方的业务必须将这些 interface 都实现。如果 interface 中有其不需要的步骤,那么只要返回 nil或者忽略就好。

View File

@ -0,0 +1,34 @@
@startuml interface-impl
interface OrderCreator
OrderCreator <|-- O2OOrderCreator
OrderCreator <|-- B2BOrderCreator
interface OrderCreator {
ValidateDistrict()
ValidateVIPProduct()
GetUserInfo()
GetProductDesc()
DecrementStorage()
CreateOrderSnapshot()
}
class O2OOrderCreator {
ValidateDistrict()
ValidateVIPProduct()
GetUserInfo()
GetProductDesc()
DecrementStorage()
CreateOrderSnapshot()
}
class B2BOrderCreator {
ValidateDistrict()
ValidateVIPProduct()
GetUserInfo()
GetProductDesc()
DecrementStorage()
CreateOrderSnapshot()
}
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB