Should you access a variable within the same class via a Property?

前端 未结 6 2018
攒了一身酷
攒了一身酷 2020-11-29 07:33

If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it.

My question is sho

6条回答
  •  无人及你
    2020-11-29 07:59

    Generally depending on the project coding standards I use a "_" or "m" preceding the name for my private class attributes. (Like below)

    private int mVariable;
    private int _Variable;
    

    With those in front of the variable I recognize right away that I'm dealing with an internal variable for the class. Then when it comes to debugging later myself or someone else can immediately recognize that the code is dealing with an internal private variable and make an adjustment. So it comes down to readability for me.

提交回复
热议问题