forked from hellokaton/write-readable-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample7.java
More file actions
53 lines (40 loc) · 1.17 KB
/
Copy pathExample7.java
File metadata and controls
53 lines (40 loc) · 1.17 KB
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
package chapter_06;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 总结性注释
*
* @author biezhi
* @date 2018/7/6
*/
public class Example7 {
private List<Long> customers = Arrays.asList(1L, 3L, 45L, 62L, 98L);
private Map<Long, List<Sale>> allSales = new HashMap<>();
static class Sale {
Long recipient;
}
public void foo() {
// 找到客户购买的所有商品
for (Long customerId: customers) {
for (Sale sale: allSales.get(customerId)) {
if (sale.recipient.equals(customerId)) {
// do something
}
}
}
}
public void generateUserReport() {
// 获取当前用户的锁
// .... 省略一部分代码
// 从数据库中读取用户的信息
// .... 省略一部分代码
// 将信息写入到文件
// .... 省略一部分代码
// 释放当前用户的锁
}
// 1. 不管你心里在想什么,先把它记录下来
// 2. 读一下这段注释,看看它有什么需要改进的
// 3. 不断改进
}