
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
62 lines
1.7 KiB
Plaintext
62 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
It may seem cleaner to omit keywords from your method declarations, but this is one time you should err on the side of verbosity. Omitting keywords in a declaration necessarily means that they'll be omitted from calls too. What results is code that will be impenetrable to maintainers. That's why it's considered best practice to always use keywords. This applies both to Objective-C-style parameters without keywords, and to C-style parameter declarations, which are deprecated.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cpp]
|
|
----
|
|
@interface MyAction
|
|
- (void)sendAction:(int)anAction :(int)flag; // Noncompliant
|
|
- (void)seekAction:(int)anAction, int flag; // Noncompliant; hard on maintainers AND deprecated
|
|
@end
|
|
|
|
void test(MyAction* myAction) {
|
|
[myAction sendAction:1 :1];
|
|
[myAction sendAction:1 forAllCells:1]; // warning: 'MyAction' may not respond to 'sendAction:forAllCells:'
|
|
[myAction seekAction:1 :1];
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cpp]
|
|
----
|
|
@interface MyAction
|
|
- (void)sendAction:(int)anAction forAllCells:(int)flag;
|
|
- (void)seekAction:(int)anAction forAllCells:(int)flag;
|
|
@end
|
|
|
|
void test(MyAction* myAction) {
|
|
[myAction sendAction:1 forAllCells:1];
|
|
[myAction seekAction:1 forAllCells:1];
|
|
}
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html[Coding Guidelines for Cocoa] - Naming Methods
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
* Add a keyword before this argument.
|
|
* Update this C-style parameter to conform to Objective-C standards.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
keyword-less arg
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|