Are there style rules for named parameters in C #?

MSDN - spaces after the colon. This is different from Objective-C, where I don't see people using a space after a colon. I think this may be a problem when the syntax highlighting has not yet caught up with this function, but I have no experience in a good IDE. MonoDevelop, which I use on a Mac with Unity, does not provide syntax coloring and autocomplete for named parameters. There are many things there; if you know what I am asking to exist inside or elsewhere, please let me know. I haven't found it yet.

+4
source share
3 answers

Microsoft has recommendations on common sense published on MSDN, in my opinion, its uniformity, which takes into account as much as the convention. If you haven’t already done so, it’s worth a look at Stylecop for styling and code standards.

Recommendations for names

From: Parameter Names

Choosing good parameter names can greatly improve the usability of your library. A good parameter name should indicate which data or functionality depends on the parameter.

Use camel shell in parameter names. Use descriptive parameter names.

In most scenarios, the parameter name and type should be sufficient to determine the use of the parameter.

Consider using names based on the parameter value rather than names based on the parameter type.

In developer tools and documentation, the parameter type is usually visible. By choosing a name that describes the use or value of a parameter, you give developers valuable information that helps them determine the right participant for their task and the right data to go to the element.

+2
source

No one forces you to use a particular style if that is what you are asking for. You can write it without spaces or with a space after the colon or with the space before the colon or with spaces around the colon, as you wish.

However IMHO, this is more readable when you use only one space after the colon.

+1
source

Style guides should appear on the development team. Each language has its own idioms that must be followed, but the details must be determined by the team. The same goes for naming conventions.

Write them down, distribute and get consent. If you are open source, I’m sure the community will give you feedback.

0
source

Source: https://habr.com/ru/post/1396764/


All Articles