Sign in to follow this  
Estauns

[.net] Class Properties Within The Class - Anything Wrong?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this