
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.
50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The ability to define default values for method arguments can make a method easier to use. Default argument values allow callers to specify as many or as few arguments as they want while getting the same functionality and minimizing boilerplate, wrapper code.
|
|
|
|
|
|
But all method arguments with default values should be declared after the method arguments without default values. Otherwise, it makes it cumbersome for callers to take advantage of defaults; they must either use named arguments or re-specify the defaulted values in order to "get to" the non-default arguments.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
class MyClass
|
|
{
|
|
public void DoStuff([Optional]int i, int j) // Noncompliant
|
|
{
|
|
// ...
|
|
}
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp]
|
|
----
|
|
class MyClass
|
|
{
|
|
public void DoStuff(int j, [Optional]int i)
|
|
{
|
|
// ...
|
|
}
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 8 Dec 2015, 09:15:59 Tamas Vajk wrote:
|
|
\[~ann.campbell.2] LGTM
|
|
|
|
endif::env-github,rspecator-view[]
|