Named arguments (parameters) as a readability aid
- by Damian Mehers
A long time ago I programmed a lot in ADA, and it was normal to name arguments when invoking a function - SomeObject.DoSomething(SomeParameterName = someValue);
Now that C# supports named arguments, I'm thinking about reverting to this habit in situations where it might not be obvious what an argument means.
You might argue that it should always be obvious what an argument means, but if you have a boolean argument, and callers are passing in "true" or "false" then qualifying the value with the name makes the call site more readable.
contentFetcher.DownloadNote(note, manual : true);
I guess I could create Enums instead of using true or false (Manual, Automatic in this case).
What do you think about occasionally using named arguments to make code easier to read?