Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with Conflicting coding conventions?

Generally we use various static code analysis tools to analyze our code for validation. But I've seen some conflicting scenarios.

As an example if we use class variables, the StyleCop will suggest us to use

this.Name = myName

instead of,

Name = myName

But this will pop up a Resharper error, "Redundant qualifier" and will suggest to not to use "this." notation.

So in such scenarios I need to check a more consistent reference to choose what is correct/Best. Is there any such resource that "defines" the correct conventions?

like image 502
Chathuranga Chandrasekara Avatar asked Jun 06 '11 09:06

Chathuranga Chandrasekara


People also ask

How do you handle conflict between developers and reviewers?

Develop a Clear, Written Process for Handling Conflict Identify and report the issue: Ask each of the team members to explain what the issue is from their perspective then schedule a meeting to discuss it further. Discussion: The relevant team members meet with a mediator to address their problems.

Do you think keeping the same programming convention within a team is important?

The importance of adhering to a coding convention, as well as a unified style of writing code, and following certain rules when building an architecture, is hard to overestimate. These are important points in the development of code, and in many ways, they are the key to the success of the product in the future.

Why is it important to follow coding guidelines and conventions?

Coding standards help you develop less complex software and, therefore, reduce errors. Improvement of the bug fixing process: with coding standards, it becomes easier for developers to locate and correct bugs in the source code because it is written in a consistent manner.


2 Answers

There is no correct convention, you adopt the one you prefer and that is your baseline/reference.

if you use both ReSharper and StyleCop you should set them up to work together meaning to accept and validate code in the same way.

like image 70
Davide Piras Avatar answered Sep 21 '22 12:09

Davide Piras


That's a subjective question, so here's my subjective answer: I agree with Resharper and think that this is redundant. Personally I prefix field names with underscore:

public class Foo
{
    private readonly string _name;

    public Foo(string name)
    {
        _name = name;
    }
}

Then I configure the static analysis tools to obey the conventions I use.

like image 43
Darin Dimitrov Avatar answered Sep 23 '22 12:09

Darin Dimitrov