---> pdfujitsu01
/icd/secure_fujitsu/Fujitsu-PD/
/icd/secure_fujitsu/Fujitsu-PD/ryon/CM5M202/CCR921352
posted @
2011-08-31 09:17 Klarke 閱讀(2617) |
評論 (0) |
編輯 收藏
好的編程原則跟好的系統設計原則和技術實施原則有著密切的聯系。下面的這些編程原則在過去的這些年里讓我成為了一名優秀的程序員,我相信,這些原則對任何一個開發人員來說,都能讓他的編程能力大幅度的提高,能讓他開發出可維護性更強、缺陷更少的程序。
我不要自我重復 — 這也許是在編程開發這最最基本的一個信條,就是要告訴你不要出現重復的代碼。我們很多的編程結構之所以存在,就是為了幫助我們消除重復(例如,循環語句, 函數,類,等等)。一旦程序里開始有重復現象的出現(例如很長的表達式、一大堆的語句,但都是為了表達相同的概念),你就需要對代碼進行一次新的提煉,抽象。
http://en.wikipedia.org/wiki/Don%27t_repeat_yourself
提煉原則 — 跟“不要自我重復原則”相關,這一原則是說“程序中任何一段具有功能性的代碼在源代碼文件中應該唯一的存在。”
http://en.wikipedia.org/wiki/Abstraction_principle_(programming)
保持簡單 — 簡單化(避免復雜)永遠都應該是你的頭等目標。簡單的程序讓你寫起來容易,產生的bug更少,更容易維護修改。
http://en.wikipedia.org/wiki/KISS_principle
不要開發你目前用不到的功能 — 除非你真正需要用到它,否則不要輕易加上那些亂七八糟用不到的功能。
http://en.wikipedia.org/wiki/YAGNI
用最簡單的方法讓程序跑起來 — 在開發時有個非常好的問題你需要問問自己,“怎樣才能最簡單的讓程序跑起來?”這能幫助我們在設計時讓程序保持簡單。
http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html
不要讓我動腦子 — 這實際上是Steve Krug 關于web界面操作的一本書的書名,但也適用于編程。主旨是,程序代碼應該讓人們花最小的努力就能讀懂和理解。如果一段程序對于閱讀者來說需要花費太多的努力才能理解,那它很可能需要進一步簡化。
http://www.sensible.com/dmmt.html
開放/封閉原則 — 程序里的實體項(類,模塊,函數等)應該對擴展行為開放,對修改行為關閉。換句話說,不要寫允許別人修改的類,應該寫能讓人們擴展的類。
http://en.wikipedia.org/wiki/Open_Closed_Principle
為維護者寫程序 — 任何值得你編寫的程序在將來都是值得你去維護的,也許由你維護,也許由他人。在將來,當你不得不維護這些程序時,你對這些代碼的記憶會基本上跟一個陌生人 一樣,所以,你最好還是當成一直在給別人寫程序。一個有助于你記住這個原則的辦法是“寫程序時時刻記著,這個將來要維護你寫的程序的人是一個有嚴重暴力傾 向,并且知道你住在哪里的精神變態者”。
http://c2.com/cgi/wiki?CodeForTheMaintainer
最少意外原則 — 最少意外原則通常是使用在用戶界面設計上,但這個原則同樣適用于編寫程序。程序代碼應盡可能的不要讓閱讀者感到意外。也就是說應該遵循編碼規范和常見習慣,按照公認的習慣方式進行組織和命名,不符常規的編程動作應該盡可能的避免。
http://en.wikipedia.org/wiki/Principle_of_least_astonishment
單一職責原則 — 一個代碼組件(例如類或函數)應該只執行單一的預設的任務。
http://en.wikipedia.org/wiki/Single_responsibility_principle
最小化耦合關系 — 一個代碼片段(代碼塊,函數,類等)應該最小化它對其它代碼的依賴。這個目標通過盡可能少的使用共享變量來實現。“低耦合是一個計算機系統結構合理、設計優秀的標志,把它與高聚合特征聯合起來,會對可讀性和可維護性等重要目標的實現具有重要的意義。”
http://en.wikipedia.org/wiki/Coupling_(computer_programming)
最大化內聚性 — 具有相似功能的代碼應該放在同一個代碼組件里。
http://en.wikipedia.org/wiki/Cohesion_(computer_science)
隱藏實現細節 — 隱藏實現細節能最小化你在修改程序組件時產生的對那些使用這個組件的其它程序模塊的影響。
http://en.wikipedia.org/wiki/Information_Hiding
笛米特法則(Law of Demeter) — 程序組件應該只跟它的直系親屬有關系(例如繼承類,內包含的對象,通過參數入口傳入的對象等。)
http://en.wikipedia.org/wiki/Law_of_Demeter
避免過早優化 — 只有當你的程序沒有其它問題,只是比你預期的要慢時,你才能去考慮優化工作。只有當其它工作都做完后,你才能考慮優化問題,而且你只應該依據經驗做法來優 化。“對于小幅度的性能改進都不該考慮,要優化就應該是97%的性能提升:過早優化是一切罪惡的根源”—Donald Knuth。
http://en.wikipedia.org/wiki/Program_optimization
代碼復用 — 這不是非常核心的原則,但它跟其它原則一樣非常有價值。代碼復用能提高程序的可靠性,節省你的開發時間。
http://en.wikipedia.org/wiki/Code_reuse
職責分離 — 不同領域的功能應該由完全不同的代碼模塊來管理,盡量減少這樣的模塊之間的重疊。http://en.wikipedia.org/wiki/Separation_of_concerns
擁抱變化 — 這是Kent Beck的一本書的副標題,它也是極限編程和敏捷開發方法的基本信條之一。很多的其它原則都基于此觀念:面對變化,歡迎變化。事實上,一些經典的軟件工程 原則,例如最小化耦合,就是為了讓程序更容易面對變化。不論你是否采用了極限編程方法,這個原則對你的程序開發都有重要意義。http://www.amazon.com/gp/product/0321278658
posted @
2011-08-18 14:01 Klarke 閱讀(191) |
評論 (0) |
編輯 收藏
restoreDesign . tri_des_rx_1
saveTestcase -dir case
PS:
restore_setting.tcl
posted @
2011-08-12 14:02 Klarke 閱讀(153) |
評論 (0) |
編輯 收藏
cvs: error while loading shared libraries: libcrypto.so.4: cannot open shared object file: No such file or directory
posted @
2011-08-08 16:06 Klarke 閱讀(107) |
評論 (0) |
編輯 收藏
Os:
uname -a
cat /etc/issue
Cpu:
cat /proc/cpuinfo
head /proc/meminfo
posted @
2011-08-05 16:02 Klarke 閱讀(97) |
評論 (0) |
編輯 收藏
Here are a few examples. Also see the documentation for the `-d' option in the previous section.
- To print the date of the day before yesterday:
date --date='2 days ago'
- To print the date of the day three months and one day hence:
date --date='3 months 1 day'
- To print the day of year of Christmas in the current year:
date --date='25 Dec' +%j
- To print the current full month name and the day of the month:
date '+%B %d'
But this may not be what you want because for the first nine days of the month, the `%d' expands to a zero-padded two-digit field, for example `date -d 1may '+%B %d'' will print `May 01'. - To print a date without the leading zero for one-digit days of the month, you can use the (GNU extension)
-
modifier to suppress the padding altogether. date -d=1may '+%B %-d'
- To print the current date and time in the format required by many non-GNU versions of
date
when setting the system clock: date +%m%d%H%M%Y.%S
- To set the system clock forward by two minutes:
date --set='+2 minutes'
- To print the date in the format specified by RFC-822, use `date --rfc'. I just did and saw this:
Mon, 25 Mar 1996 23:34:17 -0600
- To convert a date string to the number of seconds since the epoch (which is 1970-01-01 00:00:00 UTC), use the `--date' option with the `%s' format. That can be useful in sorting and/or graphing and/or comparing data by date. The following command outputs the number of the seconds since the epoch for the time one second later than the epoch, but in time zone five hours later (Cambridge, Massachusetts), thus a total of five hours and one second after the epoch:
date --date='1970-01-01 00:00:01 UTC +5 hours' +%s
18001
Suppose you had not specified time zone information in the example above. Then, date would have used your computer's idea of the time zone when interpreting the string. Here's what you would get if you were in Greenwich, England: # local time zone used
date --date='1970-01-01 00:00:01' +%s
1
- If you're sorting or graphing dated data, your raw date values may be represented as seconds since the epoch. But few people can look at the date `946684800' and casually note "Oh, that's the first second of the year 2000."
date --date='2000-01-01 UTC' +%s
946684800
To convert such an unwieldy number of seconds back to a more readable form, use a command like this: date -d '1970-01-01 946684800 sec' +"%Y-%m-%d %T %z"
2000-01-01 00:00:00 +0000
posted @
2011-08-05 15:59 Klarke 閱讀(855) |
評論 (0) |
編輯 收藏
在實際編寫程序時,經常會弄不清楚各個基本數據類型的數據表示范圍和占用的字節數。現在將C/C++的基本數據類型總結如下,所有的類型在 VS2005+32位機器+win732位操作系統 上進行了驗證。
符號屬性 長度屬性 基本型 所占位數 取值范圍 輸入符舉例 輸出符舉例
-- -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%u
signed -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%u
unsigned -- char 8 0 ~ 2^8-1 %c %c、%d、%u
[signed] short [int] 16 -2^15 ~ 2^15-1 %hd
unsigned short [int] 16 0 ~ 2^16-1 %hu、%ho、%hx
[signed] --