
寫了二十年程式,吸收了很多不同的經驗。而這些經驗部份會轉化為 Coding Styles,讓 BeyondZ 的程序員跟從。也讓同事在跟進項目時更易了解當中的邏輯。今天爆開 Starbucks HK 後,發現存在著一個名為 coding-styles.rtf 的文檔。相信那是 Starbucks HK 開發人不小心置入的檔案。這份編程指引跟我的習慣有九成相似呢!
//
// Coding Styles
// Starbucks HK
//
// Created on 8/16/12.
// All rights reserved.
//Location of Files lib - to differentiate our codes versus any external library source codes, we created this folder to put all external libraries here
model - any data/model classes to be used
controllers - all view controllers, for major view controllers, place them in root of this folder, for view controller of those smaller elements, place them in "components" folder
view - all view files, e.g. a view class for a table list item
Supporting Files - any supporting files. Most importantly, all images to be placed in the "images" folder.
Code Comments and Pragma Marks For every class, we will place the following standard comments and pragma marks to make codes consistently readable
// This class is ... (describe the purpose of this class)
//---------------------------------
// Private Functions
//---------------------------------
#pragma mark - Private Functions
//---------------------------------
// Inherited Functions
//---------------------------------
#pragma mark - Inherited Functions
//---------------------------------
// Public Functions
//---------------------------------
#pragma mark - Public Functions
//---------------------------------
// Delegate Functions
//---------------------------------
#pragma mark - Delegate Functions
//---------------------------------
// Events
//---------------------------------
#pragma mark - Events
//---------------------------------
// System Functions
//---------------------------------
#pragma mark - System Functions
Naming Conventions - For all names, try not to use short forms whenever possible
- For all class names and Folder names, try to capitalize first letter of every word, e.g. "DrinksViewController"
- For Delegates, try to put the object who is sending out this delegate in front of the function name, e.g. customTabBarMinimised, customTabBarGotoHome;
-For events, try to put the object who is sending out this event in front of the function name, e.g. homeButtonTouched