![]() Image names should be named consistently to preserve organization and developer sanity. Images should be placed in the asset catalog in all new projects. Any comments that are used must be kept up-to-date or deleted.Īn example may be a complex algorithm that cannot be broken up easily (something like JSON parsing, or other complex math or logic). When they are needed, comments should be used to explain why a particular piece of code does something. Block comments should generally be avoided, as code should be as self-documenting as possible, with only the need for intermittent, few-line explanations. In general, implementations should not include comments. In addition to the parameters and return values, each method and property should be documented with any default values or behavior that the user must understand to use the API. The easiest way to do that is to use the VVDocumenter Xcode plugin. However, you should also add Java style comments to be used to generate documentation. What the class is used for, Why you may use it, etc…Īll methods and properties should be clearly named, as mentioned above. Here are a few specific situations:Īlways include a high level description in a block comment at the top of the header file. ![]() Comments should be used when necessary for clarity. In general, code should be self-documenting. For more information on using Accessor Methods in Initializer Methods and dealloc, see should not be written out explicitly unless you need to override the default instance variable name. If you need to make your variables private, use an anonymous category as outlined in the section on private properties.ĭirect instance variable access should be avoided except in initializer methods ( init, initWithCoder:, etc…), dealloc methods and within custom setters and getters. Property definitions should be used in place of naked instance variables unless there is an extremely good reason. Note how the variables and their types are read from right to left. This is especially important when using the const qualifier, as NSString *const foo (constant pointer to NSString) is not the same as NSString const *foo (pointer to a constant NSString). ![]() Single letter variable names should be avoided except in for() loops.Īsterisks indicating pointers belong with the variable, e.g., NSString *text not NSString* text or NSString * text. Variables should be named as descriptively as possible. ![]()
0 Comments
Leave a Reply. |