Google-styleguide is a good open-source project.

Source: Internet
Author: User

Recommended Site for popular language learning: http://code.google.com/p/google-styleguide/

It parses HTML pages using XML + XSLT, and introduces each type in a gradual and progressive manner (more popular, currently including C ++, JavaScript, objective-C, and Python)Programming Language.

It can be used as internal training materials or for beginners.

Example:

Backgroundobjective-C is a very dynamic, object-oriented extension of C. it's designed to be easy to use and read, while enabling sophisticated object-oriented design. it is the primary development language for new applications on Mac OS X and the iPhone. cocoa is one of the main application frameworks on Mac OS X. it is a collection of objective-C classes that provide for rapid development of full-featured Mac OS X applications. apple has already written a very good, and widely accepted, coding guide for objective-C. google has also written a similar guide for C ++. this objective-C guide aims to be a very natural combination of Apple's and Google's general recommendations. so, before reading this Guide, please make sure you 've read: apple's cocoa coding guidelines Google's open source C ++ Style Guide note that all things that are banned in Google's c ++ guide are also banned in objective-C ++, unless explicitly noted in this document. the purpose of this document is to describe the objective-C (and objective-C ++) coding guidelines and practices that shocould be used for all Mac OS X code. generation of these guidelines have evolved and been proven over time on other projects and teams. open-source projects developed by Google conform to the requirements in this Guide. google has already released open-source code that conforms to these guidelines as part of the Google toolbox for Mac project (abbreviated GTM throughout this document ). code meant to be shared between SS different projects is a good candidate to be encoded in this repository. note that this guide is not an objective-C tutorial. we assume that the reader is familiar with the language. if you are new to objective-C or need a refresher, please read the objective-C programming language. examplethey say an example is worth a thousand words so let's start off with an example that shoshould give you a feel for the style, spacing, naming, etc. an example header file, demonstrating the correct commenting and spacing for an @ interface declaration // gtmfoo. h // fooproject // created by Greg Miller on 6/13/08. // Copyright 2008 Google, Inc. all rights reserved. // # import <Foundation/Foundation. h> // a sample class demonstrating good objective-C style. all interfaces, // categories, and Protocols (read: all top-level declarations in a header) // must be commented. comments must also be adjacent to the object they're // documenting. /// (no blank line between this comment and the interface) @ interface gtmfoo: nsobject {@ private nsstring * Foo _; nsstring * BAR _;} // returns an autoreleased instance of gmfoo. see-initwithstring: For details // about the argument. + (ID) foowithstring :( nsstring *) string; // designated initializer. | string | will be copied and assigned to | Foo _ |. -(ID) initwithstring :( nsstring *) string; // gets and sets the string for | Foo _ |. -(nsstring *) Foo;-(void) setfoo :( nsstring *) newfoo; // does some work on | blah | and returns yes if the work was completed // successfuly, and no otherwise. -(bool) doworkwithstring :( nsstring *) Blah; @ endan example source file, demonstrating the correct commenting and spacing for the @ implementation of an interface. it also includes the Reference implementations for important methods like getters and setters, init, and dealloc. /// gtmfoo. M // fooproject // created by Greg Miller on 6/13/08. // Copyright 2008 Google, Inc. all rights reserved. // # import "gtmfoo. H "@ implementation gtmfoo + (ID) foowithstring :( nsstring *) string {return [[self alloc] initwithstring: String] autorelease];} // must always override super's designated initializer. -(ID) Init {return [self initwithstring: Nil];}-(ID) initwithstring :( nsstring *) string {If (Self = [Super init]) {Foo _ = [String Copy]; BAR _ = [[nsstring alloc] initwithformat: @ "Hi % d", 3] ;}return self ;}- (void) dealloc {[Foo _ release]; [BAR _ release]; [Super dealloc];}-(nsstring *) Foo {return Foo _;}-(void) setfoo :( nsstring *) newfoo {[Foo _ autorelease]; Foo _ = [newfoo copy];}-(bool) doworkwithstring :( nsstring *) Blah {//... return no;} @ endblank lines before and after @ interface, @ implementation, and @ end are optional. if your @ interface declares instance variables, as most do, any blank line shocould come after the closing brace (}). unless an interface or implementation is very short, such as when declaring a handful of private methods or a bridge class, adding blank lines usually helps readability.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.