[.net] Class Properties Within The Class - Anything Wrong?
Is there anything semanticallyl wrong with using class properties within the class itself? One of my properties (get) calculates a value. I also need this value within the class itself. Is it okay to use this.Property or is a GetCalculatedPropertyValue() the more semantically correct way to do this?
There is no reason to not use the properties, especially if using the properties is making sure that you do everything correctly. For instance, in one of my GUI controls I always manipulate the size with the Size property, because that makes sure to lock the vertex buffer, resize, unlock, etc.
I think if you are talking about using a Property (property or a la get and set methods) instead of accessing the private member is a much better way to code if that specific member needs special values such as an integer that can only be between 0 and 5. The set/property can check against invalid values, but for regular cases like setting transparency or something of your object, like a boolean, might as well just access the private member.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement