亚洲精品久久久久久第一页-人妻少妇精彩视品一区二区三区-91国产自拍免费视频-免费一级a在线播放视频正片-少妇天天日天天射天天爽-国产大屁股喷水视频在线观看-操美女骚穴抽插性爱视频-亚洲 欧美 中文字幕 丝袜-成人免费无码片在线观看

程序員編程培訓(xùn)_每個(gè)程序員都必須知道的5條編程原則( 二 )


3.現(xiàn)在而不是將來的代碼 (3. Code for the Now not the Future)
One of the smart principles of programming is to make provisions for future changes in the code. It should be easy for a third party who was not involved in the project, to follow the logic and add or remove functionality as needed.
編程的明智原則之一是為將來的代碼更改做好準(zhǔn)備 。對(duì)于不參與項(xiàng)目的第三方來說,遵循邏輯并根據(jù)需要添加或刪除功能應(yīng)該很容易 。
Nevertheless, making provisions for future maintenance isn’t the same as coding in functionality that you might need in future. The latter only increases the volume of code while creating a new avenue for bugs. In any case, such functionality is often not needed at all in future.
但是,為將來的維護(hù)做準(zhǔn)備與將來可能需要的功能編碼不同 。后者只會(huì)增加代碼量,同時(shí) 為錯(cuò)誤 創(chuàng)建新的 途徑。無論如何,將來通常根本不需要這種功能 。
Coding for the now prevents scope creep. Unless the end user specifically requests for this functionality to be included from the onset, stay away from it.
現(xiàn)在進(jìn)行編碼可防止范圍蔓延 。除非最終用戶明確要求從一開始就包含此功能,否則請(qǐng)遠(yuǎn)離它 。
4.不要過早優(yōu)化 (4. Don’t Optimize Prematurely)
When you enroll for a basic programming course, one of the areas of emphasis is the need to create fast efficient algorithms. The mistake some coders make is to run with this one lesson. They get immersed in trying to speed up and optimize the code from the start while losing sight of the primary objective which is a creating a functioning program.
當(dāng)您注冊(cè)基礎(chǔ)編程課程時(shí),重點(diǎn)領(lǐng)域之一就是需要?jiǎng)?chuàng)建快速高效的算法 。一些編碼人員犯的錯(cuò)誤是在學(xué)習(xí)這一課時(shí) 。他們?nèi)褙炞⒂趶囊婚_始就試圖加快代碼的速度并優(yōu)化代碼,同時(shí)又忽略了創(chuàng)建功能正常的程序的主要目標(biāo) 。
Work on meeting the system requirements first then move on to optimize the code. Optimizing too early is akin to groping in the dark. Before the program is up and running, you cannot really be certain where the bottlenecks will be. You could waste precious time optimizing a function whose speed doesn’t contribute much to overall program performance.
首先要滿足系統(tǒng)要求,然后繼續(xù)進(jìn)行代碼優(yōu)化 。太早進(jìn)行優(yōu)化類似于在黑暗中摸索 。在程序啟動(dòng)并運(yùn)行之前,您無法真正確定瓶頸將在何處 。您可能會(huì)浪費(fèi)寶貴的時(shí)間來優(yōu)化功能,而該功能的速度對(duì)整體程序性能的影響并不大 。
Ergo, first satisfy the program requirements then work on resolving the bottlenecks.
因此,首先要滿足程序要求,然后再解決瓶頸 。
5.聰明的代碼之上的可讀代碼 (5. Readable Code Over Clever Code)
Clever code is programming that is less about creating easily understandable code and more about showing everyone how smart you are. A typical example of clever code is packing an excessive amount of program logic into a single line of code.
聰明的代碼是編程,而不是創(chuàng)建易于理解的代碼,而更多的是向所有人展示您的聰明程度 。聰明代碼的典型示例是將過多的 程序邏輯 打包 到一行代碼中 。
Minimal code was at one time heralded as a sign of good programming but over time, the industry has recognized that brief code is meaningless if it’s hard for someone else to follow the logic. Any line of code that would take another programmer dozens of minutes to understand should probably be done away with.
極少的代碼曾一度被認(rèn)為是良好編程的標(biāo)志,但隨著時(shí)間的流逝,業(yè)界已經(jīng)認(rèn)識(shí)到,如果其他人很難遵循邏輯,那么簡(jiǎn)短的代碼就毫無意義 ??赡苄枰渌绦騿T花費(fèi)數(shù)十分鐘才能理解的任何代碼行,都應(yīng)該刪除 。
Good programming is not only about building applications that meet the end user’s expectation but also creating code that is easy to understand. Following these programming principles will ensure you achieve both.


以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請(qǐng)您及時(shí)就醫(yī)或請(qǐng)專業(yè)人士給予相關(guān)指導(dǎo)!

「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對(duì)您有所幫助: