統一開發者編輯器 Coding Style

在多人開發專案時候,一定會遇到大家使用的編輯器大不相同 TextMate, Vim, Sublime Text 2, Geany, Notepad++…等,該如何統一程式碼的一致性呢?這邊要講得不是各種語言的 Coding Style,而是編輯器的設定,例如大家一定會遇到有的開發者使用 Tab 另外一群人使用 Space,在同一專案裡面就會發現有的 tab 有的 space,這樣看起來非常的亂,該如何統一大家的預設 indent style,就是要使用 EditorConfig 啦。使用方式很簡單,可以在專案目錄內加入 .editorconfig 內容設定如下 ; EditorConfig is awesome: http://EditorConfig.org root = true ; top-most EditorConfig file ; Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true ; 4 space indentation [*.py] indent_style = space indent_size = 4 ; Tab indentation (no size specified) [*.js] indent_style = tab ; Indentation override for all JS under lib directory [lib/**. [Read More]

寫出好維護的 PHP 程式碼

今天有機會到台中幫創業團隊制定 PHP Coding Style,相信程式設計師每天花最多時間的就是 maintain code 了,如何寫出大家都易於維護的程式碼,必須先制定團隊的 coding style 為首要目標,底下分享個人推薦的寫法給大家參考,希望對於未來維護,轉移程式碼或教育訓練剛起步的團隊有些幫助。