From 33e8f8cd677d739a625ec0a56b02036dd7b2e8a0 Mon Sep 17 00:00:00 2001 From: Zhenia Tulusha Date: Mon, 26 Jan 2015 11:59:44 +0200 Subject: [PATCH 1/3] Update README.md for Techery --- README.md | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index ab2c1b5..59dfc33 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# The official 33Devs Objective-C style guide. +# The official Techery Objective-C style guide. -This style guide outlines the coding conventions for 33Devs organization. +This style guide outlines the coding conventions for Techery organization. ## Introduction @@ -10,7 +10,7 @@ This style guide is different from other Objective-C style guides you may see, b ## Credits -We would like to thank the creators of the [New York Times](https://github.com/NYTimes/objective-c-style-guide) and [raywenderlich.com](https://github.com/raywenderlich/objective-c-style-guide) Objective-C Style Guides. These two style guides provided a solid starting point for this guide to be created and based upon. +We would like to thank the creators of the [New York Times](https://github.com/NYTimes/objective-c-style-guide), [raywenderlich.com](https://github.com/raywenderlich/objective-c-style-guide) and [33Devs](https://github.com/33devs/Objective-C-Code-Style-Guide) Objective-C Style Guides. These two style guides provided a solid starting point for this guide to be created and based upon. ## Background @@ -189,14 +189,14 @@ UIButton *settingsButton; UIButton *setBut; ``` -A three letter prefix should always be used for class names and constants, however may be omitted for Core Data entity names. For any official 33Devs projects the prefix 'TTD' or 'TEA' should be used. +A three letter prefix should always be used for class names and constants, however may be omitted for Core Data entity names. For any official Techery projects the prefix 'TEC' or 3 letters that can be identify project should be used. Constants should be camel-case with all words capitalized and prefixed by the related class name for clarity. **Preferred:** ```objc -static NSTimeInterval const TTDViewControllerNavigationFadeAnimationDuration = 0.3; +static NSTimeInterval const TECViewControllerNavigationFadeAnimationDuration = 0.3; ``` **Not Preferred:** @@ -264,7 +264,7 @@ Direct access to instance variables that 'back' properties should be avoided exc **Preferred:** ```objc -@interface TTDObject : NSObject +@interface TECObject : NSObject @property (nonatomic, strong) NSString *objectName; @@ -274,7 +274,7 @@ Direct access to instance variables that 'back' properties should be avoided exc **Not Preferred:** ```objc -@interface TTDObject : NSObject { +@interface TECObject : NSObject { NSString *objectName; } ``` @@ -362,15 +362,15 @@ Constants are preferred over in-line string literals or numbers, as they allow f **Preferred:** ```objc -static NSString * const TTDAboutViewControllerCompanyName = @"33Devs"; +static NSString * const TECAboutViewControllerCompanyName = @"Techery"; -static CGFloat const TTDImageThumbnailHeight = 50.0; +static CGFloat const TECImageThumbnailHeight = 50.0; ``` **Not Preferred:** ```objc -#define CompanyName @"33Devs" +#define CompanyName @"Techery" #define thumbnailHeight 2 ``` @@ -382,10 +382,10 @@ When using `enum`s, it is recommended to use the new fixed underlying type speci **For Example:** ```objc -typedef NS_ENUM(NSInteger, TTDLeftMenuTopItemType) { - TTDLeftMenuTopItemMain, - TTDLeftMenuTopItemShows, - TTDLeftMenuTopItemSchedule +typedef NS_ENUM(NSInteger, TECLeftMenuTopItemType) { + TECLeftMenuTopItemMain, + TECLeftMenuTopItemShows, + TECLeftMenuTopItemSchedule }; ``` @@ -393,10 +393,10 @@ You can also make explicit value assignments (showing older k-style constant def ```objc typedef NS_ENUM(NSInteger, TTDGlobalConstants) { - TTDPinSizeMin = 1, - TTDPinSizeMax = 5, - TTDPinCountMin = 100, - TTDPinCountMax = 500, + TECPinSizeMin = 1, + TECPinSizeMax = 5, + TECPinCountMin = 100, + TECPinCountMax = 500, }; ``` @@ -456,16 +456,16 @@ switch (condition) { When using an enumerated type for a switch, 'default' is not needed. For example: ```objc -TTDLeftMenuTopItemType menuType = TTDLeftMenuTopItemMain; +TECLeftMenuTopItemType menuType = TECLeftMenuTopItemMain; switch (menuType) { - case TTDLeftMenuTopItemMain: + case TECLeftMenuTopItemMain: // ... break; - case TTDLeftMenuTopItemShows: + case TECLeftMenuTopItemShows: // ... break; - case TTDLeftMenuTopItemSchedule: + case TECLeftMenuTopItemSchedule: // ... break; } @@ -474,12 +474,12 @@ switch (menuType) { ## Private Properties -Private properties should be declared in class extensions (anonymous categories) in the implementation file of a class. Named categories (such as `TTDPrivate` or `private`) should never be used unless extending another class. The Anonymous category can be shared/exposed for testing using the +Private.h file naming convention. +Private properties should be declared in class extensions (anonymous categories) in the implementation file of a class. Named categories (such as `TECPrivate` or `private`) should never be used unless extending another class. The Anonymous category can be shared/exposed for testing using the +Private.h file naming convention. **For Example:** ```objc -@interface TTDDetailViewController () +@interface TECDetailViewController () @property (nonatomic, strong) GADBannerView *googleAdView; @property (nonatomic, strong) ADBannerView *iAdView; @@ -711,6 +711,7 @@ When possible, always turn on "Treat Warnings as Errors" in the target's Build S Some other style guides that were used and processed for writing this guide: +* [33Devs](https://github.com/33devs/Objective-C-Code-Style-Guide) * [raywenderlich.com](https://github.com/raywenderlich/objective-c-style-guide) * [Robots & Pencils](https://github.com/RobotsAndPencils/objective-c-style-guide) * [New York Times](https://github.com/NYTimes/objective-c-style-guide) From 74079520a5c65c66c72ce8ca35bffefc51bc76d8 Mon Sep 17 00:00:00 2001 From: Maxim Date: Tue, 5 May 2015 13:49:40 +0300 Subject: [PATCH 2/3] My changes --- README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 59dfc33..706bc61 100644 --- a/README.md +++ b/README.md @@ -321,7 +321,7 @@ Dot-notation should **always** be used for accessing and mutating properties, as **Preferred:** ```objc -NSInteger arrayCount = [self.array count]; +NSInteger arrayCount = [self.array count]; //MAX_COMMENT : Why not just self.array.count? view.backgroundColor = [UIColor orangeColor]; [UIApplication sharedApplication].delegate; ``` @@ -651,7 +651,8 @@ When methods return an error parameter by reference, switch on the returned valu **Preferred:** ```objc NSError *error; -if (![self trySomethingWithError:&error]) { +BOOL tryingResult = [self trySomethingWithError:&error]; //MAX_COMMENT : I think, methods result should be contained in varialble for simplifying debug process. +if (!tryingResult) { // Handle Error } ``` @@ -692,7 +693,7 @@ Line breaks are an important topic since this style guide is focused for print a For example: ```objc -self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; +self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; //MAX_COMMENT : It should be isn't quite correct example for this issue. I beleive that the best practice is do not create ling method names. ``` A long line of code like this should be carried on to the second line adhering to this style guide's Spacing section (4 spaces). ```objc @@ -700,6 +701,27 @@ self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; ``` +## Method qualifier + +It should contain one space after qualifier and *NO* space after method return type + +For example: +```objc +- (void)someMethod; +- (NSString *)stringReturnMethod; ++ (id)someStaticMethod; +``` +**Not Preferred:** +```objc +-(void)someMethod; +-(void) method; +- (void) anotherMethod; +``` + +## Project Structure + +*TODO* + ## Xcode project From c8a54255240160e3b57e9a91763cdc5a63e57073 Mon Sep 17 00:00:00 2001 From: Zhenia Tulusha Date: Wed, 6 May 2015 19:44:40 +0300 Subject: [PATCH 3/3] Update README.md --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 706bc61..d59c374 100644 --- a/README.md +++ b/README.md @@ -321,7 +321,7 @@ Dot-notation should **always** be used for accessing and mutating properties, as **Preferred:** ```objc -NSInteger arrayCount = [self.array count]; //MAX_COMMENT : Why not just self.array.count? +NSInteger arrayCount = [self.array count]; view.backgroundColor = [UIColor orangeColor]; [UIApplication sharedApplication].delegate; ``` @@ -357,7 +357,7 @@ NSNumber *buildingStreetNumber = [NSNumber numberWithInteger:10018]; ## Constants -Constants are preferred over in-line string literals or numbers, as they allow for easy reproduction of commonly used variables and can be quickly changed without the need for find and replace. Constants should be declared as `static` constants and not `#define`s unless explicitly being used as a macro. +Constants are preferred over in-line string literals or numbers, as they allow for easy reproduction of commonly used variables and can be quickly changed without the need for find and replace. Constants should be declared as `static` constants and not `#define`s unless explicitly being used as a macro. If `static` constants should be used in other classes they should be predeclared in headers as `extern` constants. **Preferred:** @@ -414,25 +414,27 @@ enum GlobalConstants { ## Case Statements -Braces are not required for case statements, unless enforced by the complier. -When a case contains more than one line, braces should be added. +Braces are required for case statements. ```objc switch (condition) { - case 1: + case 1: { // ... break; + } case 2: { // ... // Multi-line example using braces break; } - case 3: + case 3: { // ... break; - default: + } + default: { // ... break; + } } ``` @@ -651,7 +653,7 @@ When methods return an error parameter by reference, switch on the returned valu **Preferred:** ```objc NSError *error; -BOOL tryingResult = [self trySomethingWithError:&error]; //MAX_COMMENT : I think, methods result should be contained in varialble for simplifying debug process. +BOOL tryingResult = [self trySomethingWithError:&error]; if (!tryingResult) { // Handle Error } @@ -693,7 +695,7 @@ Line breaks are an important topic since this style guide is focused for print a For example: ```objc -self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; //MAX_COMMENT : It should be isn't quite correct example for this issue. I beleive that the best practice is do not create ling method names. +self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; ``` A long line of code like this should be carried on to the second line adhering to this style guide's Spacing section (4 spaces). ```objc