-
Notifications
You must be signed in to change notification settings - Fork 0
/
lecture.html
118 lines (91 loc) · 2.29 KB
/
lecture.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# Understanding Dagger
---
# Agenda
1. Dependency Injection
2. Why Dagger
3. Code
תֵּן לְחָכָם וְיֶחְכַּם עוֹד הוֹדַע לְצַדִּיק וְיוֹסֶף לֶקַח.
---
# Dependency Injection
``` java
class ShoppingManager{
ShoppingManager(String country, String currency,String stripeUrl,
String stripeUsername, String password, String shoppingCartId){
TaxCalculator calculator = new TaxCalculator(country, currency);
Stripe stripe = new Stripe(stripeUrl,stripePassword);
Shoppingcart cart = ShoppingCartManager.getShoppingCart(shoppingCartId);
this.calculator = calculator;
this.stripe = stripe;
this.cart = cart;
}
public purchase(String itemId){
...
}
}
```
Unit test:
```java
class ShoppingManagerTest {
ShoppingManager manager;
@Before
public init() {
manager = new ShoppingManager("Israel", "NIS",
"https://stripe.api.com/v1", "admin", "1234", "8");
}
@test
public test() {
//get me a nice gucci coat
manager.purchase("gsdgfhgfahj")
assert(....)
}
}
```
---
# What is the problem?
---
#Dependency injection to the rescue
``` java
class ShoppingManager{
ShoppingManager(TaxCalculator calculator ,Stripe stripe, Shoppingcart cart){
this.calculator = calculator;
this.stripe = stripe;
this.cart = cart;
}
public purchase(String itemId){
...
}
}
```
---
# But now we just moved the problem
---
# Dagger to the rescue
---
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create();
</script>
</body>
</html>