All private status variables should have a public getter.

vgwizardx

New member
Things like m_bounced, m_Reequipping, m_thrown(It does have a public getter) and m_throwing for example. These statuses are all private. So if i wanted to inherit and use a class such as TrajectoryObject I can't use those variables to add new functionality without changing the base class.
 
I've gone back and forth on this one. Some variables are private because they really shouldn't be modified by a subclass. In cases like this I think that it makes more sense to add a protected property.
 
That is what I was trying to say. I'm so bad with words. I want to be able to get the value without changing what was set by the base class. So when I said public getter, I was thinking of this setup in ItemPickup:

C#:
        public bool PickedUp { get { return m_PickedUp; } }
        private bool m_PickedUp;

But basically if you want your code to be more modular and adhere to the open/close principal you should have protected properties for all of your variables. I have been making changes to some classes like ItemPickup and have to basically copy and paste the whole class to add new functionallity because I can't get the value of private variables.
 
Last edited:
Top