Skip to content

Commit 426eb05

Browse files
committed
chore(ci): blog sync
1 parent 4ad4ad6 commit 426eb05

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

data/blog/post-18.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,27 @@ tags: ["经验"]
2020

2121
## 处理 url 的时候,最好使用 encodeURIComponent
2222

23-
当我们在路由参数处理的时候,最好使用 encodeURIComponent 来保证参数传递正常,或者在对接第三方 SDK 的时候,需要注意第三方提供的文档中是否标注需要对 url 进行编码
23+
当我们在路由参数处理的时候,最好使用 encodeURIComponent 来保证参数传递正常,或者在对接第三方 SDK 的时候,需要注意第三方提供的文档中是否标注需要对 url 进行编码
24+
25+
## 魔法值
26+
27+
开发中避免直接使用 0 1 2 这种数字,应该定义一个语义化枚举,来映射具体值,提高代码可维护性
28+
29+
## 对于特殊逻辑,一定要写注释
30+
31+
在实际业务开发中,肯定会有一些看起来很奇怪的逻辑,这时候需要编写注释,来方便后面维护的人理解
32+
33+
## 边界处理
34+
35+
写完代码后,要思考不同场景,“防御性编程”
36+
37+
## 重复的事情最好交给代码
38+
39+
如果一件事需要重复做,那么就最好将其抽象为工作流,然后通过程序来实现,或者实现一部分
40+
41+
## 验证代码正确性比什么都重要
42+
43+
当完成功能,需要进行验证,这比更快上线功能重要
2444

2545
---
2646
此文自动发布于:<a href="https://github.com/coderPerseus/blog/issues/18" target="_blank">github issues</a>

0 commit comments

Comments
 (0)