korewayume's recent timeline updates
korewayume

korewayume

V2EX member #192842, joined on 2016-09-21 18:03:44 +08:00
korewayume's recent replies
工厂模式:
Factory:
if type=="a":
return new A
if type=="b":
return new B

obj = new Factory(type)

结果是 obj is A 或者 obj is B

策略模式:
Strategy:
if type=="a":
this.attribute = new A
return this
if type=="b":
this.attribute = new B
return this

obj = new Strategy(type)

结果是 obj has A() 或者 obj has B()
一个是创建型模式,一个是行为型模式
https://github.com/Ma63d/kov-blog
这个项目的后台 app 支持用 Markdown 编辑,并且支持代码片段高亮,可以看看
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2841 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 15:28 · PVG 23:28 · LAX 08:28 · JFK 11:28
♥ Do have faith in what you're doing.