We don't name parameters the same as our fields, because it's confusing. Code gets read far more often than it gets written, so readability is paramount. Having to mentally decode which uid
is the parameter, and which is the field, just isn't worth it.
We actually use an underscore prefix for our fields, to make it immediately obvious what's a field and what's a parameter / local. I know not everybody likes that convention, but we find it helpful.
In addition, for a SetXxx method like you're writing, we'll often just name the parameter value
, following the convention of C# property setters. Since there's only the one parameter, and you already know what it means from the method name, "value" is just as meaningful as "uid".
So in our shop, your example would probably end up looking like this:
public class Terminal {
private int _uid;
public void SetUid(int value) {
_uid = value;
}
}
That's assuming that the uid is write-only. If it were read-write, of course we'd use a property instead of getter/setter methods.