File tree Expand file tree Collapse file tree 3 files changed +36
-7
lines changed
creational/abstract-factory Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Original file line number Diff line number Diff line change 4
4
5
5
[ Javascript Design Pattern] ( https://www.dofactory.com/javascript/design-patterns )
6
6
7
+ [ Learning JavaScript Design Patterns] ( https://addyosmani.com/resources/essentialjsdesignpatterns/book/ )
8
+
7
9
## Types of Design Patterns
8
10
9
11
- [ Creational] ( #creational )
Original file line number Diff line number Diff line change 1
- * [ ] 多态
2
- * [ ] bind/call/apply 的实现
3
- * [ ] Javascript 原生方法的实现
4
- * [ ] 使用小网页的方式来实现设计模式
5
- * [ ] 抽象 log helper
6
- * [ ] 设计原则
7
- * [ ] 使用 Chain of Responsibility Pattern 和 State Pattern 两种模式来写红绿灯变化
1
+ - [ ] 多态
2
+ - [ ] bind/call/apply 的实现
3
+ - [ ] Javascript 原生方法的实现
4
+ - [ ] 使用小网页的方式来实现设计模式
5
+ - [ ] 抽象 log helper
6
+ - [ ] 设计原则
7
+ - [ ] doc.md
8
+ - [ ] 使用 Chain of Responsibility Pattern 和 State Pattern 两种模式来写红绿灯变化
Original file line number Diff line number Diff line change
1
+ function droidProducer ( kind ) {
2
+ if ( kind === 'battle' ) return battleDroidFactory
3
+ return pilotDroidFactory
4
+ }
5
+
6
+ function battleDroidFactory ( ) {
7
+ return new B1 ( )
8
+ }
9
+
10
+ function pilotDroidFactory ( ) {
11
+ return new Rx24 ( )
12
+ }
13
+
14
+ class B1 {
15
+ info ( ) {
16
+ return 'B1, Battle Droid'
17
+ }
18
+ }
19
+
20
+ class Rx24 {
21
+ info ( ) {
22
+ return 'Rx24, Pilot Droid'
23
+ }
24
+ }
25
+
26
+ export default droidProducer
You can’t perform that action at this time.
0 commit comments