As kind of a follow up to this question about prefixes, I agree with most people on the thread that prefixes are bad. But what about if you are using getters and setters? Then you need to differeniate the publicly accessible getter name from the privately stored variable. I normally just use an underscore, but is there a better way?
This is a completely subjective question. There is no "better" way.
One way is:
private int _x;
public get x():int { return _x; }
public set x(int val):void { _x = val; }
Another is:
private int x;
public get X():int { return x; }
public set X(int val):void { x = val; }
Neither is the right answer. Each has style advantages and disadvantages. Pick the one you like best and apply it consistently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With