[Adium-devl] Coding style
Colin Barrett
timber at lava.net
Fri Mar 3 01:33:37 UTC 2006
The first example contains an error, it should be:
- (char *)UTF8String
{
if (UTF8String == NULL) {
UTF8String = malloc([self length]);
}
if (UTF8String != NULL) {
strcpy(UTF8String, "I am the Walrus");
}
return UTF8String;
}
The second example is entirely correct. The wording is confusing.
Here is an example that shows correct usage.
if (foo) {
quux();
} else if (bar) {
xyzzy();
} else {
exit();
}
The wiki will be updated to fix these errors shortly.
Thanks!
-Colin
On Mar 2, 2006, at 3:01 PM, Magnus Markling wrote:
> Hi!
>
> I just noticed some inconsistencies in the example in the Adium coding
> guidelines.
>
>
> "Braces for method/function *beginning* and end go on their own
> lines."
>
> Check the first brace here:
>
> - (char *) UTF8String {
> if (UTF8String == NULL) {
> UTF8String = malloc([self length]);
> }
>
> if (UTF8String != NULL) {
> strcpy(UTF8String, "I am the Walrus");
> }
>
> return UTF8String;
> }
>
>
> "Braces for if and else statements begin on the same line as the
> statement
> and *end* on their own lines."
>
> The braces before 'else' are NOT on their own line.
>
> - (BOOL)textAndButtonsWindowDidEnd:(NSWindow *)window
> returnCode:(AITextAndButtonsReturnCode)returnCode userInfo:(id)
> userInfo
> {
> if (returnCode == AITextAndButtonsDefaultReturn) {
> //A single comment can use double-slash to explain the
> following line of code
> [self gotDefaultReturn];
> } else if (returnCode == AITextAndButtonsOtherReturn) {
> /* A multi-line comment should be formatted
> * like this and explain the code below. Write
> your code so
> it is understandable without comments...
> * and comment it! This helps you and helps future
> programmers work with your code.
> */
> [self gotOtherReturn];
> } else {
> [self displayError];
> }
> }
>
> Regards
> MEMark
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20060302/e84be43c/attachment-0001.html>
More information about the devel
mailing list