Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 755720f

Browse files
docs(rule): Python 编码准则
1 parent a9777a4 commit 755720f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎rule.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- Martin Fowler 先生曾经说过:"代码有很多种坏味道,重复是最坏的一种!"
2+
- 尽量减少对全局变量的使用:
3+
1. 全局变量的作用域和影响过于广泛,可能会发生意料之外的修改和使用
4+
2. 全局变量比局部变量拥有更长的生命周期,可能导致对象占用的内存长时间无法被 [垃圾回收](https://zh.wikipedia.org/wiki/%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6_(%E8%A8%88%E7%AE%97%E6%A9%9F%E7%A7%91%E5%AD%B8))
5+
3. 减少对全局变量的使用,也是降低代码之间耦合度的一个重要举措
6+
4.[迪米特法则](https://zh.wikipedia.org/zh-hans/%E5%BE%97%E5%A2%A8%E5%BF%92%E8%80%B3%E5%AE%9A%E5%BE%8B) 的践行

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /