selfteaching / selfteaching/selfteaching-python-camp
Day08 好代码不是一次性写出来的,而是一次次review,一次次迭代优化出来的
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
这两天练习的题目,都是在一个项目上不停地迭代更新,用学到的新东西,优化自己的代码,使之更加"健壮",其实这是教会我们一个能力就是不停地review自己的代码,好的代码(最佳实践)都不是一口气写出来的,都是在自己最原始版本上慢慢迭代出来的
比如说最开始的代码只是完成了最基础的功能(刚好完成需求),只要输入参数一变代码马上就报错不能运行了,例如统计单词频率的第一天,我们输入的参数(文本)都是教员们提供好的文字,而我们写出来的代码就好像是专门为执行这段文字"定制"出来的代码也就是通用性很差,如果我们自己随便在网上找一段文字作为参数再次运行,这段代码很可能会报错,这就是前面说的代码不够健壮
而随后几天我们的任务慢慢的增加了为函数将代码封装为一个或者多个函数,增加了module可以将多个函数抽离出来形成单独的文件,降低了以后维护的难度, 增加了异常处理机制,可以在函数执行过程中出现的异常或者将传入的参数异常主动的抛离(raise)出来,代码的适用性越来越强
总结: 好代码不是一次性写出来的,而是一次次review,一次次迭代优化出来的
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue is a reflection on reviewing and improving Python code, but it names no file, test, or entry point to inspect. Clarify whether any repository change is expected and define the intended documentation or code outcome before starting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 10/100