Developing good programming habits is the first prerequisite for starting a new language.
(1) document structure specifications
1. Create a Libs folder to store third-party libraries.
2. Create a Tools Folder to store your own encapsulated class libraries.
3. Create a ViewControllers folder to store all ViewControl
4. Create a Request folder to store network requests
5. Create a Cell folder to store the list items
6. Create related folders such as Images, Music, and Video in the Supporting Files folder to store Images, audios, videos, and other resources respectively.
7. Create the homepage of RootViewController and place it in the underlying directory
8. Create a Constant. h file, store it in the underlying directory, and store constants.
Example:
(2) Naming rules
1. The constant names are all in uppercase and can be separated by underscores (_), for example, MY_LOTTERY_ID.
2. lowercase variable letters, followed by uppercase letters, such as myLotteryId
3. The first letter of the class name is capitalized, for example, @ interface MyLotteryId: NSObject
4. The name must contain a type, such as xxxTv, xxxView, and xxxStr.
Common types are abbreviated as follows:
UIViewController: VC UIImage: Img UIImageView: Iv
UIView: View UILabel: Lbl UIButton: Btn
UINavigationBar: NBar UIToolBar: TBar UISearchBar: SBar
UITextField: Tf UITextView: TV NSArray: Array
NSMutableArray: MArray NSDictionary: Dict NSMutableDictionary: MDict
NSString: Str NSMutableString: MStr NSSet: Set NSMutableSet: MSet
5. Add the s sign before the static variable, such as sLotteryId
For more naming conventions, see the official documentation of apple.
(3) coding habits
1. Briefly describe the role of each file
2. Use # pragma mark in the function module of the class to make remarks for convenient searching and code management.
3. Delete NSLog after testing
4. The variable method name in the program should be marked by the naming function whenever possible. Annotations cannot be used to describe the variables.
5. Load preprocessing and Automatic log removal settings in the pch File
6. The number of lines of the class code should not exceed 300, and a function should not exceed 100. If the number of lines exceeds, consider refactoring.
7. Create a Constant. h file storage Constant