putongdeshu / google-styleguide

Automatically exported from code.google.com/p/google-styleguide
0 stars 0 forks source link

Objective-C style guide: incorrect statement about property implementation directives #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the Objective-C style guide section for Properties 
(https://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Properties), 
subsection "List out all implementation directives", it says that properties 
are @dynamic by default (and thus one should list them out), which is not 
correct.

Apple's documentation 
(http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Objective
C/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW9 
Objective-C Programming Language, section "Property Implementation Directives") 
clearly states that using @dynamic is *different* from not using an 
implementation directive, in that the compiler will issue a warning for missing 
getters and setters when no implementation directive is given, but it will not 
issue a warning when @dynamic is used. It suggests that @dynamic be used in 
situations where you will fulfill the property contract in another way, such as 
dynamic loading of code or dynamic method resolution; such mechanisms are 
highly unlikely to be used in most code.

Therefore, the style guide's instruction to add a @dynamic directive, when 
there was no directive, actually makes the code WORSE, because it turns off a 
very useful compiler warning about missing getters and setters, without any 
benefit at all.

Original issue reported on code.google.com by spoon.re...@gmail.com on 23 Jun 2011 at 1:57

GoogleCodeExporter commented 9 years ago
This is fixed in the Objective-C Style Guide 2.36 release at r75.

Original comment by mark@chromium.org on 4 Nov 2011 at 6:04

GoogleCodeExporter commented 9 years ago

Original comment by mark@chromium.org on 4 Nov 2011 at 6:04

GoogleCodeExporter commented 9 years ago

Original comment by mark@chromium.org on 4 Nov 2011 at 9:18