Skip to content

Commit 2837098

Browse files
committed
function
1 parent c500d07 commit 2837098

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎205.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@
200200

201201
还是前面的观点,这个程序你或许也发现了需要进一步优化的地方,那就太好了。另外,关于判断质数的方法,还有好多种,读者可以自己创造或者网上搜索一些,拓展思路。
202202

203+
##编写函数的注意事项
204+
205+
编写函数,在开发实践中是非常必要和常见的,一般情况,你写的函数应该是:
206+
207+
1. 尽量不要使用全局变量。
208+
2. 如果参数是可变类型数据,在函数内,不要修改它。
209+
3. 每个函数的功能和目标要单纯,不要试图一个函数做很多事情。
210+
4. 函数的代码行数尽量少。
211+
5. 函数的独立性越强越好,不要跟其它的外部东西产生关联。
212+
203213
------
204214

205215
[总目录](./index.md)   |   [上节:函数(4)](./204.md)   |   [下节:类(1)](./206.md)

0 commit comments

Comments
 (0)