The Register® — Biting the hand that feeds IT

Feeds
Bronze badge

Properties vs Accessors

Yes, the get/set method syntax is a bit burdensome. But the alternative has its problems, too.

When coding in C# I found myself forced into silly naming conventions to prevent conflict and ambiguity between member field names and property methods. (Made ten times worse by a ridiculous Style Nazi add-on to Visual Studio that used to bitch about naming conventions - probably written by the jerk who did the grammar warnings in MS Word.)

The problem rarely arises when using the public interface to a class. Few experienced coders expose fields these days. But it needs to be clear in member methods whether we're accessing the field or the property.

Given the choice between get/set and having to call fields things like "mName", I think I prefer the former. It's mainly because "getName", "setName" and "name" have a relationship that's clear from reading them, but also because, in my heade at least, "mName" sounds like a cross between "M'Lud" and "My Computer".