Variable Naming (Hungarian revisited)

A friend asked me today if I preferred to add a scoping prefix to variable with class scope like so:

private int m_MyInt;

There was a time when I did do this (VB5 era), but mostly because I couldn't use just a proceeding underscore C style. When I started using C# I quickly moved back to C style naming:

private int _myInt;

However, I find myself ignoring the friendly underscore these days in favor of just plain meaningful names. The only time I find myself reaching for the top row anymore is when the underscore adds clarity. Such as when my meaningful names collide.

public class Relationship
{
private
readonly int id; private readonly bool isEnrolled; public
Relationship(int id, bool isEnrolled) { this.id = id; this.isEnrolled = isEnrolled; } }

This to me is getting icky. So I fire up my trusty sidkick Resharper and do some judicious renaming with the following results.

private readonly int _id;
private readonly bool _isEnrolled;
public Relationship(int id, bool isEnrolled)
{
	_id = id;
	_isEnrolled = isEnrolled;
}

For me these kinds of patterns only show up in DTOs otherwise I tend not to carry around a lot of class scoped variables.