Which one is recommended while writing Clean Code in C# or it doesn't matter?
a)
int count = 0, sum = 0;
b)
int count = 0;
int sum = 0;
I personally write code with b) style. I almost forgot that we can declare variables like a) style. So is there any coding style about that in Clean Code
CodePudding user response:
There is no problem using a style but I think the best choice for clean code would be style b because of better readability.
CodePudding user response:
It's cleaner when you declare the variables in separate lines even if they are of the same type, it is easier to read and understand your code.
and it's easy to add or remove variables in future.
There could be a situation when it's convenient to declare the variables on the same line if they are very closely related like int height = 0, width = 0;
.
But again its opinion based and what standard is followed in your team/organization.