- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
改良程序的技巧(Techniques for improving procedures)
改良程序的技巧(Techniques for improving procedures)
There are many reasons why we should write clear and readable programs. The most important thing is that you write only once, but you will read it countless times later. When you look back at your code for second days, youre going to start reading it. When you show the code to someone else, he has to read your code. So, spend more time in writing, and you will
There are many reasons why we should write clear and readable programs. The most important thing is that you write only once, but you will read it countless times later. When you look back at your code for second days, youre going to start reading it. When you show the code to someone else, he has to read your code. So, spend more time writing, and youll save a lot of time while reading it.
Lets look at some basic programming techniques:
1. try to keep the method short
2. never ever use the same variable for several different purposes
3. use self described variable names and method names
4. define variables as close as possible to where they are used
5. deny mysterious numbers
6. be friendly to your language
7. dont go against the routine
8. guard against premature optimization
9. actively refactor the tested program
10. dont indulge in skills
11. learn new knowledge through examples
Now, lets expand each of these dots in detail.
1. try to keep the method short
Although many people follow this rule, it is still very important. The method you write can always be placed in one screen. If you need to scroll the screen, it distracts you, and you cant see the whole context. The best length is 5-20 lines, which depends on your case. Of course, getters/setters is usually a line of code, but rather than a real method, they are just access tools.
2. never ever use the same variable for several different purposes
A variable should always serve only one purpose. By making variable constant (C++ const, Java final), the compiler can optimize the compiler, and make your code stri
您可能关注的文档
- 【专题论说】论人类观念的转变([Topic] on the change of human concept).doc
- 【人文常识】容易混用的近义成语辨析40例([humanities and common sense] 40 cases of easy to discriminate idioms).doc
- 【人物】描写人物动作成语([characters] describe characters, actions, idioms).doc
- 【免费】热带鱼常见病的防治([free] prevention and treatment of common diseases of tropical fish).doc
- 【卡牌三国】关卡详集,通关宝典([card Three Kingdoms] level set, customs clearance collection).doc
- 【原】剩女剩男都是宝([original] leftover women, left men are treasures).doc
- 【习题】中国新闻事业史重点及习题([problem] the history and the problems of Chinese Journalism).doc
- 【原创】粤教版高二级语文《传记选读》模块结业测试([original] Cantonese Education Edition, high grade language biography selected reading module test).doc
- 【古代诗文】常见古今异义词([ancient poetry] common ancient words).doc
- 【名品花木】苗木风害预防([Famous] flowers and seedlings wind damage prevention).doc
- 改良焦性没食子酸法培养厌氧菌(Improved pyrogallic acid method of anaerobic bacteria culture).doc
- 改进的活性污泥法 同步氧化池法研究简介(Brief introduction of improved activated sludge process simultaneous oxidation tank method).doc
- 改性膨润土吸附处理含cr(vi)废水的研究管理(Study on the treatment of Wastewater Containing Cr (VI) by Modified Bentonite).doc
- 改错 数字(Digital error correction).doc
- 改进封面设计 责编责无旁贷(The cover design is improved commissioning editor).doc
- 改过的fz决斗快牛(FZ's duel, bull!).doc
- 改革的历史(History of reform).doc
- 放射医学中级考试复习(Review of intermediate examination of Radiation Medicine).doc
- 放下包袱 轻松上阵——谈考研面试紧张焦虑情绪的应对(Lay down the burden and go into battle easily -- Talking about the coping with anxiety and anxiety in the entrance examination for postgraduate entrance examination).doc
- 放射科常用x线投照技术常规(下)(Routine radiography technique in radiology department (lower)).doc
文档评论(0)