-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AV1561: Update for tuples and local functions #104
Comments
I believe the essence of this rule is to limit the number of values that are passed to a method. The goal of that would be to keep the method body simple. And to prevent flooding the readers' mind with a large set of states (variables, parameters, fields) to be tracked, while analyzing the execution flow. If the goal is to limit the number of values to be tracked, then maybe that should also apply for the return value (now that we can have multiple). Perhaps this rule should be rephrased to constrain the total number of values going in and out. If set to 4, that would allow: public (string first, string second) DoWork(string input, string other); but not: public (string first, string second, string third) DoWork(string input, string other); |
That makes sense indeed. In fact, a tuple with more than two values should be frowned upon. |
Another thing to consider are the naming conventions as @boekabart asked about in his gist. After reading this article I tend to lean towards this:
So names of the tuple members use Pascal casing when returning them . Why do you think @bkoelman ? |
Interesting, I need to experiment and think about this some more...
But unfortunately I've been in the hospital for two weeks now. I'm in much
pain and cannot think clearly most of the time. Hope to come back to this
later.
Op 23 jan. 2018 7:41 a.m. schreef "Dennis Doomen" <notifications@github.com
:
Another thing to consider are the naming conventions as @boekabart
<https://github.com/boekabart> asked about in his gist
<https://gist.github.com/boekabart/98fbb8a351a289f66e58f128a1284752>. After
reading this article
<https://msdn.microsoft.com/en-us/magazine/mt493248.aspx?f=255&MSPPError=-2147217396>
I tend to lean towards this:
public (string First, string Second) DoWork(string input, string other);
So names of the tuple members use Pascal casing when returning them .
Why do you think @bkoelman <https://github.com/bkoelman> ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#104 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ2JlFTdFvPg9-gHwonTa7ABYanNFAMsks5tNX8YgaJpZM4P0rk3>
.
|
Oh crap. Hope you recover soon. Nothing critical?
From: Bart Koelman [mailto:notifications@github.com]
Sent: Friday, February 2, 2018 10:59 AM
To: dennisdoomen/CSharpGuidelines <CSharpGuidelines@noreply.github.com>
Cc: Dennis Doomen <Dennis.Doomen@avivasolutions.nl>; Comment <comment@noreply.github.com>
Subject: Re: [dennisdoomen/CSharpGuidelines] AV1561: Update for tuples and local functions (#104)
Interesting, I need to experiment and think about this some more...
But unfortunately I've been in the hospital for two weeks now. I'm in much
pain and cannot think clearly most of the time. Hope to come back to this
later.
Op 23 jan. 2018 7:41 a.m. schreef "Dennis Doomen" <notifications@github.com
<mailto:notifications@github.com%0b>>:
Another thing to consider are the naming conventions as @boekabart
<https://github.com/boekabart> asked about in his gist
<https://gist.github.com/boekabart/98fbb8a351a289f66e58f128a1284752>. After
reading this article
<https://msdn.microsoft.com/en-us/magazine/mt493248.aspx?f=255&MSPPError=-2147217396>
I tend to lean towards this:
public (string First, string Second) DoWork(string input, string other);
So names of the tuple members use Pascal casing when returning them .
Why do you think @bkoelman <https://github.com/bkoelman> ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#104 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ2JlFTdFvPg9-gHwonTa7ABYanNFAMsks5tNX8YgaJpZM4P0rk3>
.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#104 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAi9PiFRss3p8mDbhKuSelcRkoMroTt3ks5tQtxygaJpZM4P0rk3>.
|
Not sure yet. Various treatments are not working. I'll be moving to an
academical hospital soon.
Op 2 feb. 2018 11:05 a.m. schreef "Dennis Doomen" <notifications@github.com
…:
Oh crap. Hope you recover soon. Nothing critical?
From: Bart Koelman ***@***.***
Sent: Friday, February 2, 2018 10:59 AM
To: dennisdoomen/CSharpGuidelines ***@***.***>
Cc: Dennis Doomen ***@***.***>; Comment <
***@***.***>
Subject: Re: [dennisdoomen/CSharpGuidelines] AV1561: Update for tuples
and local functions (#104)
Interesting, I need to experiment and think about this some more...
But unfortunately I've been in the hospital for two weeks now. I'm in much
pain and cannot think clearly most of the time. Hope to come back to this
later.
Op 23 jan. 2018 7:41 a.m. schreef "Dennis Doomen" <
***@***.***
***@***.***%0b>>:
Another thing to consider are the naming conventions as @boekabart
<https://github.com/boekabart> asked about in his gist
<https://gist.github.com/boekabart/98fbb8a351a289f66e58f128a1284752>.
After
reading this article
<https://msdn.microsoft.com/en-us/magazine/mt493248.aspx?
f=255&MSPPError=-2147217396>
I tend to lean towards this:
public (string First, string Second) DoWork(string input, string other);
So names of the tuple members use Pascal casing when returning them .
Why do you think @bkoelman <https://github.com/bkoelman> ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#104 (comment)-
359691376>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ2JlFTdFvPg9-
gHwonTa7ABYanNFAMsks5tNX8YgaJpZM4P0rk3>
.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://github.com/
dennisdoomen/CSharpGuidelines#104#issuecomment-362540951>, or mute
the thread<https://github.com/notifications/unsubscribe-auth/
AAi9PiFRss3p8mDbhKuSelcRkoMroTt3ks5tQtxygaJpZM4P0rk3>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#104 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ2JlKawCrqhpyJ2UfuQXLUVxMQbcIW_ks5tQt4DgaJpZM4P0rk3>
.
|
Existing rule:
Don't allow methods and constructors with more than three parameters (AV1561)
If you create a method with more than three parameters, use a structure or class to pass multiple arguments, as explained in the [Specification design pattern](http://en.wikipedia.org/wiki/Specification_pattern). In general, the fewer the parameters, the easier it is to understand the method. Additionally, unit testing a method with many parameters requires many scenarios to test.
New language features to consider:
The next method signature accepts five values, but would be allowed by this rule in its current form:
However, blocking usage of tuples seems a bit too strict to me. Perhaps allow tuples, but limit their maximum number of items? Alternatively, count the tuple items separately? That would allow a method with two parameters, where the second parameter is a tuple with two items.
This rule should probably also apply for local functions and delegates. We could change the first line to:
If you create a method
, local function or delegate
with more than three parameters...
The text was updated successfully, but these errors were encountered: